home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 6 / CU Amiga Magazine's Super CD-ROM 06 (1996)(EMAP Images)(GB)(Track 1 of 4)[!][issue 1997-01].iso / cucd / prog / gnu-c / src / gcc-2.7.0-amiga / calls.c < prev    next >
C/C++ Source or Header  |  1995-08-24  |  103KB  |  3,199 lines

  1. /* Convert function calls to rtl insns, for GNU C compiler.
  2.    Copyright (C) 1989, 1992, 1993, 1994, 1995 Free Software Foundation, Inc.
  3.  
  4. This file is part of GNU CC.
  5.  
  6. GNU CC is free software; you can redistribute it and/or modify
  7. it under the terms of the GNU General Public License as published by
  8. the Free Software Foundation; either version 2, or (at your option)
  9. any later version.
  10.  
  11. GNU CC is distributed in the hope that it will be useful,
  12. but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14. GNU General Public License for more details.
  15.  
  16. You should have received a copy of the GNU General Public License
  17. along with GNU CC; see the file COPYING.  If not, write to
  18. the Free Software Foundation, 59 Temple Place - Suite 330,
  19. Boston, MA 02111-1307, USA.  */
  20.  
  21. #include "config.h"
  22. #include "rtl.h"
  23. #include "tree.h"
  24. #include "flags.h"
  25. #include "expr.h"
  26. #ifdef __STDC__
  27. #include <stdarg.h>
  28. #else
  29. #include <varargs.h>
  30. #endif
  31. #include "insn-flags.h"
  32.  
  33. /* Decide whether a function's arguments should be processed
  34.    from first to last or from last to first.
  35.  
  36.    They should if the stack and args grow in opposite directions, but
  37.    only if we have push insns.  */
  38.  
  39. #ifdef PUSH_ROUNDING
  40.  
  41. #if defined (STACK_GROWS_DOWNWARD) != defined (ARGS_GROW_DOWNWARD)
  42. #define PUSH_ARGS_REVERSED    /* If it's last to first */
  43. #endif
  44.  
  45. #endif
  46.  
  47. /* Like STACK_BOUNDARY but in units of bytes, not bits.  */
  48. #define STACK_BYTES (STACK_BOUNDARY / BITS_PER_UNIT)
  49.  
  50. /* Data structure and subroutines used within expand_call.  */
  51.  
  52. struct arg_data
  53. {
  54.   /* Tree node for this argument.  */
  55.   tree tree_value;
  56.   /* Mode for value; TYPE_MODE unless promoted.  */
  57.   enum machine_mode mode;
  58.   /* Current RTL value for argument, or 0 if it isn't precomputed.  */
  59.   rtx value;
  60.   /* Initially-compute RTL value for argument; only for const functions.  */
  61.   rtx initial_value;
  62.   /* Register to pass this argument in, 0 if passed on stack, or an
  63.      EXPR_LIST if the arg is to be copied into multiple different
  64.      registers.  */
  65.   rtx reg;
  66.   /* If REG was promoted from the actual mode of the argument expression,
  67.      indicates whether the promotion is sign- or zero-extended.  */
  68.   int unsignedp;
  69.   /* Number of registers to use.  0 means put the whole arg in registers.
  70.      Also 0 if not passed in registers.  */
  71.   int partial;
  72.   /* Non-zero if argument must be passed on stack.
  73.      Note that some arguments may be passed on the stack
  74.      even though pass_on_stack is zero, just because FUNCTION_ARG says so.
  75.      pass_on_stack identifies arguments that *cannot* go in registers.  */
  76.   int pass_on_stack;
  77.   /* Offset of this argument from beginning of stack-args.  */
  78.   struct args_size offset;
  79.   /* Similar, but offset to the start of the stack slot.  Different from
  80.      OFFSET if this arg pads downward.  */
  81.   struct args_size slot_offset;
  82.   /* Size of this argument on the stack, rounded up for any padding it gets,
  83.      parts of the argument passed in registers do not count.
  84.      If REG_PARM_STACK_SPACE is defined, then register parms
  85.      are counted here as well.  */
  86.   struct args_size size;
  87.   /* Location on the stack at which parameter should be stored.  The store
  88.      has already been done if STACK == VALUE.  */
  89.   rtx stack;
  90.   /* Location on the stack of the start of this argument slot.  This can
  91.      differ from STACK if this arg pads downward.  This location is known
  92.      to be aligned to FUNCTION_ARG_BOUNDARY.  */
  93.   rtx stack_slot;
  94. #ifdef ACCUMULATE_OUTGOING_ARGS
  95.   /* Place that this stack area has been saved, if needed.  */
  96.   rtx save_area;
  97. #endif
  98. #ifdef STRICT_ALIGNMENT
  99.   /* If an argument's alignment does not permit direct copying into registers,
  100.      copy in smaller-sized pieces into pseudos.  These are stored in a
  101.      block pointed to by this field.  The next field says how many
  102.      word-sized pseudos we made.  */
  103.   rtx *aligned_regs;
  104.   int n_aligned_regs;
  105. #endif
  106. };
  107.  
  108. #ifdef ACCUMULATE_OUTGOING_ARGS
  109. /* A vector of one char per byte of stack space.  A byte if non-zero if
  110.    the corresponding stack location has been used.
  111.    This vector is used to prevent a function call within an argument from
  112.    clobbering any stack already set up.  */
  113. static char *stack_usage_map;
  114.  
  115. /* Size of STACK_USAGE_MAP.  */
  116. static int highest_outgoing_arg_in_use;
  117.  
  118. /* stack_arg_under_construction is nonzero when an argument may be
  119.    initialized with a constructor call (including a C function that
  120.    returns a BLKmode struct) and expand_call must take special action
  121.    to make sure the object being constructed does not overlap the
  122.    argument list for the constructor call.  */
  123. int stack_arg_under_construction;
  124. #endif
  125.  
  126. static int calls_function    PROTO((tree, int));
  127. static int calls_function_1    PROTO((tree, int));
  128. static void emit_call_1        PROTO((rtx, tree, tree, int, int, rtx, rtx,
  129.                        int, rtx, int));
  130. static void store_one_arg    PROTO ((struct arg_data *, rtx, int, int,
  131.                     tree, int));
  132.  
  133. /* If WHICH is 1, return 1 if EXP contains a call to the built-in function
  134.    `alloca'.
  135.  
  136.    If WHICH is 0, return 1 if EXP contains a call to any function.
  137.    Actually, we only need return 1 if evaluating EXP would require pushing
  138.    arguments on the stack, but that is too difficult to compute, so we just
  139.    assume any function call might require the stack.  */
  140.  
  141. static tree calls_function_save_exprs;
  142.  
  143. static int
  144. calls_function (exp, which)
  145.      tree exp;
  146.      int which;
  147. {
  148.   int val;
  149.   calls_function_save_exprs = 0;
  150.   val = calls_function_1 (exp, which);
  151.   calls_function_save_exprs = 0;
  152.   return val;
  153. }
  154.  
  155. static int
  156. calls_function_1 (exp, which)
  157.      tree exp;
  158.      int which;
  159. {
  160.   register int i;
  161.   enum tree_code code = TREE_CODE (exp);
  162.   int type = TREE_CODE_CLASS (code);
  163.   int length = tree_code_length[(int) code];
  164.  
  165.   /* If this code is language-specific, we don't know what it will do.  */
  166.   if ((int) code >= NUM_TREE_CODES)
  167.     return 1;
  168.  
  169.   /* Only expressions and references can contain calls.  */
  170.   if (type != 'e' && type != '<' && type != '1' && type != '2' && type != 'r'
  171.       && type != 'b')
  172.     return 0;
  173.  
  174.   switch (code)
  175.     {
  176.     case CALL_EXPR:
  177.       if (which == 0)
  178.     return 1;
  179.       else if (TREE_CODE (TREE_OPERAND (exp, 0)) == ADDR_EXPR
  180.            && (TREE_CODE (TREE_OPERAND (TREE_OPERAND (exp, 0), 0))
  181.            == FUNCTION_DECL))
  182.     {
  183.       tree fndecl = TREE_OPERAND (TREE_OPERAND (exp, 0), 0);
  184.  
  185.       if ((DECL_BUILT_IN (fndecl)
  186.            && DECL_FUNCTION_CODE (fndecl) == BUILT_IN_ALLOCA)
  187.           || (DECL_SAVED_INSNS (fndecl)
  188.           && (FUNCTION_FLAGS (DECL_SAVED_INSNS (fndecl))
  189.               & FUNCTION_FLAGS_CALLS_ALLOCA)))
  190.         return 1;
  191.     }
  192.  
  193.       /* Third operand is RTL.  */
  194.       length = 2;
  195.       break;
  196.  
  197.     case SAVE_EXPR:
  198.       if (SAVE_EXPR_RTL (exp) != 0)
  199.     return 0;
  200.       if (value_member (exp, calls_function_save_exprs))
  201.     return 0;
  202.       calls_function_save_exprs = tree_cons (NULL_TREE, exp,
  203.                          calls_function_save_exprs);
  204.       return (TREE_OPERAND (exp, 0) != 0
  205.           && calls_function_1 (TREE_OPERAND (exp, 0), which));
  206.  
  207.     case BLOCK:
  208.       {
  209.     register tree local;
  210.  
  211.     for (local = BLOCK_VARS (exp); local; local = TREE_CHAIN (local))
  212.       if (DECL_INITIAL (local) != 0
  213.           && calls_function_1 (DECL_INITIAL (local), which))
  214.         return 1;
  215.       }
  216.       {
  217.     register tree subblock;
  218.  
  219.     for (subblock = BLOCK_SUBBLOCKS (exp);
  220.          subblock;
  221.          subblock = TREE_CHAIN (subblock))
  222.       if (calls_function_1 (subblock, which))
  223.         return 1;
  224.       }
  225.       return 0;
  226.  
  227.     case METHOD_CALL_EXPR:
  228.       length = 3;
  229.       break;
  230.  
  231.     case WITH_CLEANUP_EXPR:
  232.       length = 1;
  233.       break;
  234.  
  235.     case RTL_EXPR:
  236.       return 0;
  237.     }
  238.  
  239.   for (i = 0; i < length; i++)
  240.     if (TREE_OPERAND (exp, i) != 0
  241.     && calls_function_1 (TREE_OPERAND (exp, i), which))
  242.       return 1;
  243.  
  244.   return 0;
  245. }
  246.  
  247. /* Force FUNEXP into a form suitable for the address of a CALL,
  248.    and return that as an rtx.  Also load the static chain register
  249.    if FNDECL is a nested function.
  250.  
  251.    CALL_FUSAGE points to a variable holding the prospective
  252.    CALL_INSN_FUNCTION_USAGE information.  */
  253.  
  254. rtx
  255. prepare_call_address (funexp, fndecl, call_fusage, reg_parm_seen)
  256.      rtx funexp;
  257.      tree fndecl;
  258.      rtx *call_fusage;
  259.      int reg_parm_seen;
  260. {
  261.   rtx static_chain_value = 0;
  262.  
  263.   funexp = protect_from_queue (funexp, 0);
  264.  
  265.   if (fndecl != 0)
  266.     /* Get possible static chain value for nested function in C. */
  267.     static_chain_value = lookup_static_chain (fndecl);
  268.  
  269.   /* Make a valid memory address and copy constants thru pseudo-regs,
  270.      but not for a constant address if -fno-function-cse.  */
  271.   if (GET_CODE (funexp) != SYMBOL_REF)
  272.     funexp =
  273. #ifdef SMALL_REGISTER_CLASSES
  274.     /* If we are using registers for parameters, force the
  275.      function address into a register now.  */
  276.       reg_parm_seen ? force_not_mem (memory_address (FUNCTION_MODE, funexp))
  277.             :
  278. #endif
  279.               memory_address (FUNCTION_MODE, funexp);
  280.   else
  281.     {
  282. #ifndef NO_FUNCTION_CSE
  283.       if (optimize && ! flag_no_function_cse)
  284. #ifdef NO_RECURSIVE_FUNCTION_CSE
  285.     if (fndecl != current_function_decl)
  286. #endif
  287.       funexp = force_reg (Pmode, funexp);
  288. #endif
  289.     }
  290.  
  291.   if (static_chain_value != 0)
  292.     {
  293.       emit_move_insn (static_chain_rtx, static_chain_value);
  294.  
  295.       if (GET_CODE (static_chain_rtx) == REG)
  296.     use_reg (call_fusage, static_chain_rtx);
  297.     }
  298.  
  299.   return funexp;
  300. }
  301.  
  302. /* Generate instructions to call function FUNEXP,
  303.    and optionally pop the results.
  304.    The CALL_INSN is the first insn generated.
  305.  
  306.    FNDECL is the declaration node of the function.  This is given ot the
  307.    macro RETURN_POPS_ARGS to determine whether this function pops its own args.
  308.  
  309.    FUNTYPE is the data type of the function, or, for a library call,
  310.    the identifier for the name of the call.  This is given to the
  311.    macro RETURN_POPS_ARGS to determine whether this function pops its own args.
  312.  
  313.    STACK_SIZE is the number of bytes of arguments on the stack,
  314.    rounded up to STACK_BOUNDARY; zero if the size is variable.
  315.    This is both to put into the call insn and
  316.    to generate explicit popping code if necessary.
  317.  
  318.    STRUCT_VALUE_SIZE is the number of bytes wanted in a structure value.
  319.    It is zero if this call doesn't want a structure value.
  320.  
  321.    NEXT_ARG_REG is the rtx that results from executing
  322.      FUNCTION_ARG (args_so_far, VOIDmode, void_type_node, 1)
  323.    just after all the args have had their registers assigned.
  324.    This could be whatever you like, but normally it is the first
  325.    arg-register beyond those used for args in this call,
  326.    or 0 if all the arg-registers are used in this call.
  327.    It is passed on to `gen_call' so you can put this info in the call insn.
  328.  
  329.    VALREG is a hard register in which a value is returned,
  330.    or 0 if the call does not return a value.
  331.  
  332.    OLD_INHIBIT_DEFER_POP is the value that `inhibit_defer_pop' had before
  333.    the args to this call were processed.
  334.    We restore `inhibit_defer_pop' to that value.
  335.  
  336.    CALL_FUSAGE is either empty or an EXPR_LIST of USE expressions that
  337.    denote registers used by the called function.
  338.  
  339.    IS_CONST is true if this is a `const' call.  */
  340.  
  341. static void
  342. emit_call_1 (funexp, fndecl, funtype, stack_size, struct_value_size, 
  343.              next_arg_reg, valreg, old_inhibit_defer_pop, call_fusage,
  344.          is_const)
  345.      rtx funexp;
  346.      tree fndecl;
  347.      tree funtype;
  348.      int stack_size;
  349.      int struct_value_size;
  350.      rtx next_arg_reg;
  351.      rtx valreg;
  352.      int old_inhibit_defer_pop;
  353.      rtx call_fusage;
  354.      int is_const;
  355. {
  356.   rtx stack_size_rtx = GEN_INT (stack_size);
  357.   rtx struct_value_size_rtx = GEN_INT (struct_value_size);
  358.   rtx call_insn;
  359.   int already_popped = 0;
  360.  
  361.   /* Ensure address is valid.  SYMBOL_REF is already valid, so no need,
  362.      and we don't want to load it into a register as an optimization,
  363.      because prepare_call_address already did it if it should be done.  */
  364.   if (GET_CODE (funexp) != SYMBOL_REF)
  365.     funexp = memory_address (FUNCTION_MODE, funexp);
  366.  
  367. #ifndef ACCUMULATE_OUTGOING_ARGS
  368. #if defined (HAVE_call_pop) && defined (HAVE_call_value_pop)
  369.   if (HAVE_call_pop && HAVE_call_value_pop
  370.       && (RETURN_POPS_ARGS (fndecl, funtype, stack_size) > 0 
  371.           || stack_size == 0))
  372.     {
  373.       rtx n_pop = GEN_INT (RETURN_POPS_ARGS (fndecl, funtype, stack_size));
  374.       rtx pat;
  375.  
  376.       /* If this subroutine pops its own args, record that in the call insn
  377.      if possible, for the sake of frame pointer elimination.  */
  378.  
  379.       if (valreg)
  380.     pat = gen_call_value_pop (valreg,
  381.                   gen_rtx (MEM, FUNCTION_MODE, funexp),
  382.                   stack_size_rtx, next_arg_reg, n_pop);
  383.       else
  384.     pat = gen_call_pop (gen_rtx (MEM, FUNCTION_MODE, funexp),
  385.                 stack_size_rtx, next_arg_reg, n_pop);
  386.  
  387.       emit_call_insn (pat);
  388.       already_popped = 1;
  389.     }
  390.   else
  391. #endif
  392. #endif
  393.  
  394. #if defined (HAVE_call) && defined (HAVE_call_value)
  395.   if (HAVE_call && HAVE_call_value)
  396.     {
  397.       if (valreg)
  398.     emit_call_insn (gen_call_value (valreg,
  399.                     gen_rtx (MEM, FUNCTION_MODE, funexp),
  400.                     stack_size_rtx, next_arg_reg,
  401.                     NULL_RTX));
  402.       else
  403.     emit_call_insn (gen_call (gen_rtx (MEM, FUNCTION_MODE, funexp),
  404.                   stack_size_rtx, next_arg_reg,
  405.                   struct_value_size_rtx));
  406.     }
  407.   else
  408. #endif
  409.     abort ();
  410.  
  411.   /* Find the CALL insn we just emitted.  */
  412.   for (call_insn = get_last_insn ();
  413.        call_insn && GET_CODE (call_insn) != CALL_INSN;
  414.        call_insn = PREV_INSN (call_insn))
  415.     ;
  416.  
  417.   if (! call_insn)
  418.     abort ();
  419.  
  420.   /* Put the register usage information on the CALL.  If there is already
  421.      some usage information, put ours at the end.  */
  422.   if (CALL_INSN_FUNCTION_USAGE (call_insn))
  423.     {
  424.       rtx link;
  425.  
  426.       for (link = CALL_INSN_FUNCTION_USAGE (call_insn); XEXP (link, 1) != 0;
  427.        link = XEXP (link, 1))
  428.     ;
  429.  
  430.       XEXP (link, 1) = call_fusage;
  431.     }
  432.   else
  433.     CALL_INSN_FUNCTION_USAGE (call_insn) = call_fusage;
  434.  
  435.   /* If this is a const call, then set the insn's unchanging bit.  */
  436.   if (is_const)
  437.     CONST_CALL_P (call_insn) = 1;
  438.  
  439.   /* Restore this now, so that we do defer pops for this call's args
  440.      if the context of the call as a whole permits.  */
  441.   inhibit_defer_pop = old_inhibit_defer_pop;
  442.  
  443. #ifndef ACCUMULATE_OUTGOING_ARGS
  444.   /* If returning from the subroutine does not automatically pop the args,
  445.      we need an instruction to pop them sooner or later.
  446.      Perhaps do it now; perhaps just record how much space to pop later.
  447.  
  448.      If returning from the subroutine does pop the args, indicate that the
  449.      stack pointer will be changed.  */
  450.  
  451.   if (stack_size != 0 && RETURN_POPS_ARGS (fndecl, funtype, stack_size) > 0)
  452.     {
  453.       if (!already_popped)
  454.     CALL_INSN_FUNCTION_USAGE (call_insn) =
  455.        gen_rtx (EXPR_LIST, VOIDmode,
  456.             gen_rtx (CLOBBER, VOIDmode, stack_pointer_rtx),
  457.             CALL_INSN_FUNCTION_USAGE (call_insn));
  458.       stack_size -= RETURN_POPS_ARGS (fndecl, funtype, stack_size);
  459.       stack_size_rtx = GEN_INT (stack_size);
  460.     }
  461.  
  462.   if (stack_size != 0)
  463.     {
  464.       if (flag_defer_pop && inhibit_defer_pop == 0 && !is_const)
  465.     pending_stack_adjust += stack_size;
  466.       else
  467.     adjust_stack (stack_size_rtx);
  468.     }
  469. #endif
  470. }
  471.  
  472. /* Generate all the code for a function call
  473.    and return an rtx for its value.
  474.    Store the value in TARGET (specified as an rtx) if convenient.
  475.    If the value is stored in TARGET then TARGET is returned.
  476.    If IGNORE is nonzero, then we ignore the value of the function call.  */
  477.  
  478. rtx
  479. expand_call (exp, target, ignore)
  480.      tree exp;
  481.      rtx target;
  482.      int ignore;
  483. {
  484.   /* List of actual parameters.  */
  485.   tree actparms = TREE_OPERAND (exp, 1);
  486.   /* RTX for the function to be called.  */
  487.   rtx funexp;
  488.   /* Tree node for the function to be called (not the address!).  */
  489.   tree funtree;
  490.   /* Data type of the function.  */
  491.   tree funtype;
  492.   /* Declaration of the function being called,
  493.      or 0 if the function is computed (not known by name).  */
  494.   tree fndecl = 0;
  495.   char *name = 0;
  496.  
  497.   /* Register in which non-BLKmode value will be returned,
  498.      or 0 if no value or if value is BLKmode.  */
  499.   rtx valreg;
  500.   /* Address where we should return a BLKmode value;
  501.      0 if value not BLKmode.  */
  502.   rtx structure_value_addr = 0;
  503.   /* Nonzero if that address is being passed by treating it as
  504.      an extra, implicit first parameter.  Otherwise,
  505.      it is passed by being copied directly into struct_value_rtx.  */
  506.   int structure_value_addr_parm = 0;
  507.   /* Size of aggregate value wanted, or zero if none wanted
  508.      or if we are using the non-reentrant PCC calling convention
  509.      or expecting the value in registers.  */
  510.   int struct_value_size = 0;
  511.   /* Nonzero if called function returns an aggregate in memory PCC style,
  512.      by returning the address of where to find it.  */
  513.   int pcc_struct_value = 0;
  514.  
  515.   /* Number of actual parameters in this call, including struct value addr.  */
  516.   int num_actuals;
  517.   /* Number of named args.  Args after this are anonymous ones
  518.      and they must all go on the stack.  */
  519.   int n_named_args;
  520.   /* Count arg position in order args appear.  */
  521.   int argpos;
  522.  
  523.   /* Vector of information about each argument.
  524.      Arguments are numbered in the order they will be pushed,
  525.      not the order they are written.  */
  526.   struct arg_data *args;
  527.  
  528.   /* Total size in bytes of all the stack-parms scanned so far.  */
  529.   struct args_size args_size;
  530.   /* Size of arguments before any adjustments (such as rounding).  */
  531.   struct args_size original_args_size;
  532.   /* Data on reg parms scanned so far.  */
  533.   CUMULATIVE_ARGS args_so_far;
  534.   /* Nonzero if a reg parm has been scanned.  */
  535.   int reg_parm_seen;
  536.   /* Nonzero if this is an indirect function call.  */
  537.   int current_call_is_indirect = 0;
  538.  
  539.   /* Nonzero if we must avoid push-insns in the args for this call. 
  540.      If stack space is allocated for register parameters, but not by the
  541.      caller, then it is preallocated in the fixed part of the stack frame.
  542.      So the entire argument block must then be preallocated (i.e., we
  543.      ignore PUSH_ROUNDING in that case).  */
  544.  
  545. #if defined(REG_PARM_STACK_SPACE) && ! defined(OUTGOING_REG_PARM_STACK_SPACE)
  546.   int must_preallocate = 1;
  547. #else
  548. #ifdef PUSH_ROUNDING
  549.   int must_preallocate = 0;
  550. #else
  551.   int must_preallocate = 1;
  552. #endif
  553. #endif
  554.  
  555.   /* Size of the stack reserved for parameter registers.  */
  556.   int reg_parm_stack_space = 0;
  557.  
  558.   /* 1 if scanning parms front to back, -1 if scanning back to front.  */
  559.   int inc;
  560.   /* Address of space preallocated for stack parms
  561.      (on machines that lack push insns), or 0 if space not preallocated.  */
  562.   rtx argblock = 0;
  563.  
  564.   /* Nonzero if it is plausible that this is a call to alloca.  */
  565.   int may_be_alloca;
  566.   /* Nonzero if this is a call to setjmp or a related function.  */
  567.   int returns_twice;
  568.   /* Nonzero if this is a call to `longjmp'.  */
  569.   int is_longjmp;
  570.   /* Nonzero if this is a call to an inline function.  */
  571.   int is_integrable = 0;
  572.   /* Nonzero if this is a call to a `const' function.
  573.      Note that only explicitly named functions are handled as `const' here.  */
  574.   int is_const = 0;
  575.   /* Nonzero if this is a call to a `volatile' function.  */
  576.   int is_volatile = 0;
  577. #if defined(ACCUMULATE_OUTGOING_ARGS) && defined(REG_PARM_STACK_SPACE)
  578.   /* Define the boundary of the register parm stack space that needs to be
  579.      save, if any.  */
  580.   int low_to_save = -1, high_to_save;
  581.   rtx save_area = 0;        /* Place that it is saved */
  582. #endif
  583.  
  584. #ifdef ACCUMULATE_OUTGOING_ARGS
  585.   int initial_highest_arg_in_use = highest_outgoing_arg_in_use;
  586.   char *initial_stack_usage_map = stack_usage_map;
  587. #endif
  588.  
  589.   rtx old_stack_level = 0;
  590.   int old_pending_adj = 0;
  591.   int old_stack_arg_under_construction;
  592.   int old_inhibit_defer_pop = inhibit_defer_pop;
  593.   tree old_cleanups = cleanups_this_call;
  594.   rtx call_fusage = 0;
  595.   register tree p;
  596.   register int i, j;
  597.  
  598.   /* See if we can find a DECL-node for the actual function.
  599.      As a result, decide whether this is a call to an integrable function.  */
  600.  
  601.   p = TREE_OPERAND (exp, 0);
  602.   if (TREE_CODE (p) == ADDR_EXPR)
  603.     {
  604.       fndecl = TREE_OPERAND (p, 0);
  605.       if (TREE_CODE (fndecl) != FUNCTION_DECL)
  606.     fndecl = 0;
  607.       else
  608.     {
  609.       if (!flag_no_inline
  610.           && fndecl != current_function_decl
  611.           && DECL_INLINE (fndecl)
  612.           && DECL_SAVED_INSNS (fndecl))
  613.         is_integrable = 1;
  614.       else if (! TREE_ADDRESSABLE (fndecl))
  615.         {
  616.           /* In case this function later becomes inlinable,
  617.          record that there was already a non-inline call to it.
  618.  
  619.          Use abstraction instead of setting TREE_ADDRESSABLE
  620.          directly.  */
  621.           if (DECL_INLINE (fndecl) && warn_inline && !flag_no_inline)
  622.         {
  623.           warning_with_decl (fndecl, "can't inline call to `%s'");
  624.           warning ("called from here");
  625.         }
  626.           mark_addressable (fndecl);
  627.         }
  628.  
  629.       if (TREE_READONLY (fndecl) && ! TREE_THIS_VOLATILE (fndecl)
  630.           && TYPE_MODE (TREE_TYPE (exp)) != VOIDmode)
  631.         is_const = 1;
  632.  
  633.       if (TREE_THIS_VOLATILE (fndecl))
  634.         is_volatile = 1;
  635.     }
  636.     }
  637.  
  638.   /* If we don't have specific function to call, see if we have a 
  639.      constant or `noreturn' function from the type.  */
  640.   if (fndecl == 0)
  641.     {
  642.       is_const = TREE_READONLY (TREE_TYPE (TREE_TYPE (p)));
  643.       is_volatile = TREE_THIS_VOLATILE (TREE_TYPE (TREE_TYPE (p)));
  644.     }
  645.  
  646. #ifdef REG_PARM_STACK_SPACE
  647. #ifdef MAYBE_REG_PARM_STACK_SPACE
  648.   reg_parm_stack_space = MAYBE_REG_PARM_STACK_SPACE;
  649. #else
  650.   reg_parm_stack_space = REG_PARM_STACK_SPACE (fndecl);
  651. #endif
  652. #endif
  653.  
  654.   /* Warn if this value is an aggregate type,
  655.      regardless of which calling convention we are using for it.  */
  656.   if (warn_aggregate_return && AGGREGATE_TYPE_P (TREE_TYPE (exp)))
  657.     warning ("function call has aggregate value");
  658.  
  659.   /* Set up a place to return a structure.  */
  660.  
  661.   /* Cater to broken compilers.  */
  662.   if (aggregate_value_p (exp))
  663.     {
  664.       /* This call returns a big structure.  */
  665.       is_const = 0;
  666.  
  667. #ifdef PCC_STATIC_STRUCT_RETURN
  668.       {
  669.     pcc_struct_value = 1;
  670.     /* Easier than making that case work right.  */
  671.     if (is_integrable)
  672.       {
  673.         /* In case this is a static function, note that it has been
  674.            used.  */
  675.         if (! TREE_ADDRESSABLE (fndecl))
  676.           mark_addressable (fndecl);
  677.         is_integrable = 0;
  678.       }
  679.       }
  680. #else /* not PCC_STATIC_STRUCT_RETURN */
  681.       {
  682.     struct_value_size = int_size_in_bytes (TREE_TYPE (exp));
  683.  
  684.     if (target && GET_CODE (target) == MEM)
  685.       structure_value_addr = XEXP (target, 0);
  686.     else
  687.       {
  688.         /* Assign a temporary on the stack to hold the value.  */
  689.  
  690.         /* For variable-sized objects, we must be called with a target
  691.            specified.  If we were to allocate space on the stack here,
  692.            we would have no way of knowing when to free it.  */
  693.  
  694.         if (struct_value_size < 0)
  695.           abort ();
  696.  
  697.         structure_value_addr
  698.           = XEXP (assign_stack_temp (BLKmode, struct_value_size, 1), 0);
  699.         MEM_IN_STRUCT_P (structure_value_addr)
  700.           = AGGREGATE_TYPE_P (TREE_TYPE (exp));
  701.         target = 0;
  702.       }
  703.       }
  704. #endif /* not PCC_STATIC_STRUCT_RETURN */
  705.     }
  706.  
  707.   /* If called function is inline, try to integrate it.  */
  708.  
  709.   if (is_integrable)
  710.     {
  711.       rtx temp;
  712.       rtx before_call = get_last_insn ();
  713.  
  714.       temp = expand_inline_function (fndecl, actparms, target,
  715.                      ignore, TREE_TYPE (exp),
  716.                      structure_value_addr);
  717.  
  718.       /* If inlining succeeded, return.  */
  719.       if ((HOST_WIDE_INT) temp != -1)
  720.     {
  721.       if (flag_short_temps)
  722.         {
  723.           /* Perform all cleanups needed for the arguments of this
  724.          call (i.e. destructors in C++).  It is ok if these
  725.          destructors clobber RETURN_VALUE_REG, because the
  726.          only time we care about this is when TARGET is that
  727.          register.  But in C++, we take care to never return
  728.          that register directly.  */
  729.           expand_cleanups_to (old_cleanups);
  730.         }
  731.  
  732. #ifdef ACCUMULATE_OUTGOING_ARGS
  733.       /* If the outgoing argument list must be preserved, push
  734.          the stack before executing the inlined function if it
  735.          makes any calls.  */
  736.  
  737.       for (i = reg_parm_stack_space - 1; i >= 0; i--)
  738.         if (i < highest_outgoing_arg_in_use && stack_usage_map[i] != 0)
  739.           break;
  740.  
  741.       if (stack_arg_under_construction || i >= 0)
  742.         {
  743.           rtx insn = NEXT_INSN (before_call), seq;
  744.  
  745.           /* Look for a call in the inline function code.
  746.          If OUTGOING_ARGS_SIZE (DECL_SAVED_INSNS (fndecl)) is
  747.          nonzero then there is a call and it is not necessary
  748.          to scan the insns.  */
  749.  
  750.           if (OUTGOING_ARGS_SIZE (DECL_SAVED_INSNS (fndecl)) == 0)
  751.         for (; insn; insn = NEXT_INSN (insn))
  752.           if (GET_CODE (insn) == CALL_INSN)
  753.             break;
  754.  
  755.           if (insn)
  756.         {
  757.           /* Reserve enough stack space so that the largest
  758.              argument list of any function call in the inline
  759.              function does not overlap the argument list being
  760.              evaluated.  This is usually an overestimate because
  761.              allocate_dynamic_stack_space reserves space for an
  762.              outgoing argument list in addition to the requested
  763.              space, but there is no way to ask for stack space such
  764.              that an argument list of a certain length can be
  765.              safely constructed.  */
  766.  
  767.           int adjust = OUTGOING_ARGS_SIZE (DECL_SAVED_INSNS (fndecl));
  768. #ifdef REG_PARM_STACK_SPACE
  769.           /* Add the stack space reserved for register arguments
  770.              in the inline function.  What is really needed is the
  771.              largest value of reg_parm_stack_space in the inline
  772.              function, but that is not available.  Using the current
  773.              value of reg_parm_stack_space is wrong, but gives
  774.              correct results on all supported machines.  */
  775.           adjust += reg_parm_stack_space;
  776. #endif
  777.           start_sequence ();
  778.           emit_stack_save (SAVE_BLOCK, &old_stack_level, NULL_RTX);
  779.           allocate_dynamic_stack_space (GEN_INT (adjust),
  780.                         NULL_RTX, BITS_PER_UNIT);
  781.           seq = get_insns ();
  782.           end_sequence ();
  783.           emit_insns_before (seq, NEXT_INSN (before_call));
  784.           emit_stack_restore (SAVE_BLOCK, old_stack_level, NULL_RTX);
  785.         }
  786.         }
  787. #endif
  788.  
  789.       /* If the result is equivalent to TARGET, return TARGET to simplify
  790.          checks in store_expr.  They can be equivalent but not equal in the
  791.          case of a function that returns BLKmode.  */
  792.       if (temp != target && rtx_equal_p (temp, target))
  793.         return target;
  794.       return temp;
  795.     }
  796.  
  797.       /* If inlining failed, mark FNDECL as needing to be compiled
  798.      separately after all.  If function was declared inline,
  799.      give a warning.  */
  800.       if (DECL_INLINE (fndecl) && warn_inline && !flag_no_inline
  801.       && ! TREE_ADDRESSABLE (fndecl))
  802.     {
  803.       warning_with_decl (fndecl, "inlining failed in call to `%s'");
  804.       warning ("called from here");
  805.     }
  806.       mark_addressable (fndecl);
  807.     }
  808.  
  809.   /* When calling a const function, we must pop the stack args right away,
  810.      so that the pop is deleted or moved with the call.  */
  811.   if (is_const)
  812.     NO_DEFER_POP;
  813.  
  814.   function_call_count++;
  815.  
  816.   if (fndecl && DECL_NAME (fndecl))
  817.     name = IDENTIFIER_POINTER (DECL_NAME (fndecl));
  818.  
  819.   /* On some machines (such as the PA) indirect calls have a different
  820.      calling convention than normal calls.  FUNCTION_ARG in the target
  821.      description can look at current_call_is_indirect to determine which
  822.      calling convention to use.  */
  823.   current_call_is_indirect = (fndecl == 0);
  824. #if 0
  825.     = TREE_CODE (TREE_OPERAND (exp, 0)) == NON_LVALUE_EXPR ? 1 : 0;
  826. #endif
  827.  
  828. #if 0
  829.   /* Unless it's a call to a specific function that isn't alloca,
  830.      if it has one argument, we must assume it might be alloca.  */
  831.  
  832.   may_be_alloca =
  833.     (!(fndecl != 0 && strcmp (name, "alloca"))
  834.      && actparms != 0
  835.      && TREE_CHAIN (actparms) == 0);
  836. #else
  837.   /* We assume that alloca will always be called by name.  It
  838.      makes no sense to pass it as a pointer-to-function to
  839.      anything that does not understand its behavior.  */
  840.   may_be_alloca =
  841.     (name && ((IDENTIFIER_LENGTH (DECL_NAME (fndecl)) == 6
  842.          && name[0] == 'a'
  843.          && ! strcmp (name, "alloca"))
  844.         || (IDENTIFIER_LENGTH (DECL_NAME (fndecl)) == 16
  845.             && name[0] == '_'
  846.             && ! strcmp (name, "__builtin_alloca"))));
  847. #endif
  848.  
  849.   /* See if this is a call to a function that can return more than once
  850.      or a call to longjmp.  */
  851.  
  852.   returns_twice = 0;
  853.   is_longjmp = 0;
  854.  
  855.   if (name != 0 && IDENTIFIER_LENGTH (DECL_NAME (fndecl)) <= 15)
  856.     {
  857.       char *tname = name;
  858.  
  859.       /* Disregard prefix _, __ or __x.  */
  860.       if (name[0] == '_')
  861.     {
  862.       if (name[1] == '_' && name[2] == 'x')
  863.         tname += 3;
  864.       else if (name[1] == '_')
  865.         tname += 2;
  866.       else
  867.         tname += 1;
  868.     }
  869.  
  870.       if (tname[0] == 's')
  871.     {
  872.       returns_twice
  873.         = ((tname[1] == 'e'
  874.         && (! strcmp (tname, "setjmp")
  875.             || ! strcmp (tname, "setjmp_syscall")))
  876.            || (tname[1] == 'i'
  877.            && ! strcmp (tname, "sigsetjmp"))
  878.            || (tname[1] == 'a'
  879.            && ! strcmp (tname, "savectx")));
  880.       if (tname[1] == 'i'
  881.           && ! strcmp (tname, "siglongjmp"))
  882.         is_longjmp = 1;
  883.     }
  884.       else if ((tname[0] == 'q' && tname[1] == 's'
  885.         && ! strcmp (tname, "qsetjmp"))
  886.            || (tname[0] == 'v' && tname[1] == 'f'
  887.            && ! strcmp (tname, "vfork")))
  888.     returns_twice = 1;
  889.  
  890.       else if (tname[0] == 'l' && tname[1] == 'o'
  891.            && ! strcmp (tname, "longjmp"))
  892.     is_longjmp = 1;
  893.     }
  894.  
  895.   if (may_be_alloca)
  896.     current_function_calls_alloca = 1;
  897.  
  898.   /* Don't let pending stack adjusts add up to too much.
  899.      Also, do all pending adjustments now
  900.      if there is any chance this might be a call to alloca.  */
  901.  
  902.   if (pending_stack_adjust >= 32
  903.       || (pending_stack_adjust > 0 && may_be_alloca))
  904.     do_pending_stack_adjust ();
  905.  
  906.   /* Operand 0 is a pointer-to-function; get the type of the function.  */
  907.   funtype = TREE_TYPE (TREE_OPERAND (exp, 0));
  908.   if (TREE_CODE (funtype) != POINTER_TYPE)
  909.     abort ();
  910.   funtype = TREE_TYPE (funtype);
  911.  
  912.   /* Push the temporary stack slot level so that we can free any temporaries
  913.      we make.  */
  914.   push_temp_slots ();
  915.  
  916.   /* Start updating where the next arg would go.  */
  917.   INIT_CUMULATIVE_ARGS (args_so_far, funtype, NULL_RTX);
  918.  
  919.   /* If struct_value_rtx is 0, it means pass the address
  920.      as if it were an extra parameter.  */
  921.   if (structure_value_addr && struct_value_rtx == 0)
  922.     {
  923.       /* If structure_value_addr is a REG other than
  924.      virtual_outgoing_args_rtx, we can use always use it.  If it
  925.      is not a REG, we must always copy it into a register.
  926.      If it is virtual_outgoing_args_rtx, we must copy it to another
  927.      register in some cases.  */
  928.       rtx temp = (GET_CODE (structure_value_addr) != REG
  929. #ifdef ACCUMULATE_OUTGOING_ARGS
  930.           || (stack_arg_under_construction
  931.               && structure_value_addr == virtual_outgoing_args_rtx)
  932. #endif
  933.           ? copy_addr_to_reg (structure_value_addr)
  934.           : structure_value_addr);
  935.  
  936.       actparms
  937.     = tree_cons (error_mark_node,
  938.              make_tree (build_pointer_type (TREE_TYPE (funtype)),
  939.                 temp),
  940.              actparms);
  941.       structure_value_addr_parm = 1;
  942.     }
  943.  
  944.   /* Count the arguments and set NUM_ACTUALS.  */
  945.   for (p = actparms, i = 0; p; p = TREE_CHAIN (p)) i++;
  946.   num_actuals = i;
  947.  
  948.   /* Compute number of named args.
  949.      Normally, don't include the last named arg if anonymous args follow.
  950.      We do include the last named arg if STRICT_ARGUMENT_NAMING is defined.
  951.      (If no anonymous args follow, the result of list_length is actually
  952.      one too large.  This is harmless.)
  953.  
  954.      If SETUP_INCOMING_VARARGS is defined and STRICT_ARGUMENT_NAMING is not,
  955.      this machine will be able to place unnamed args that were passed in
  956.      registers into the stack.  So treat all args as named.  This allows the
  957.      insns emitting for a specific argument list to be independent of the
  958.      function declaration.
  959.  
  960.      If SETUP_INCOMING_VARARGS is not defined, we do not have any reliable
  961.      way to pass unnamed args in registers, so we must force them into
  962.      memory.  */
  963. #if !defined(SETUP_INCOMING_VARARGS) || defined(STRICT_ARGUMENT_NAMING)
  964.   if (TYPE_ARG_TYPES (funtype) != 0)
  965.     n_named_args
  966.       = (list_length (TYPE_ARG_TYPES (funtype))
  967. #ifndef STRICT_ARGUMENT_NAMING
  968.      /* Don't include the last named arg.  */
  969.      - 1
  970. #endif
  971.      /* Count the struct value address, if it is passed as a parm.  */
  972.      + structure_value_addr_parm);
  973.   else
  974. #endif
  975.     /* If we know nothing, treat all args as named.  */
  976.     n_named_args = num_actuals;
  977.  
  978.   /* Make a vector to hold all the information about each arg.  */
  979.   args = (struct arg_data *) alloca (num_actuals * sizeof (struct arg_data));
  980.   bzero ((char *) args, num_actuals * sizeof (struct arg_data));
  981.  
  982.   args_size.constant = 0;
  983.   args_size.var = 0;
  984.  
  985.   /* In this loop, we consider args in the order they are written.
  986.      We fill up ARGS from the front or from the back if necessary
  987.      so that in any case the first arg to be pushed ends up at the front.  */
  988.  
  989. #ifdef PUSH_ARGS_REVERSED
  990.   i = num_actuals - 1, inc = -1;
  991.   /* In this case, must reverse order of args
  992.      so that we compute and push the last arg first.  */
  993. #else
  994.   i = 0, inc = 1;
  995. #endif
  996.  
  997.   /* I counts args in order (to be) pushed; ARGPOS counts in order written.  */
  998.   for (p = actparms, argpos = 0; p; p = TREE_CHAIN (p), i += inc, argpos++)
  999.     {
  1000.       tree type = TREE_TYPE (TREE_VALUE (p));
  1001.       int unsignedp;
  1002.       enum machine_mode mode;
  1003.  
  1004.       args[i].tree_value = TREE_VALUE (p);
  1005.  
  1006.       /* Replace erroneous argument with constant zero.  */
  1007.       if (type == error_mark_node || TYPE_SIZE (type) == 0)
  1008.     args[i].tree_value = integer_zero_node, type = integer_type_node;
  1009.  
  1010.       /* If TYPE is a transparent union, pass things the way we would
  1011.      pass the first field of the union.  We have already verified that
  1012.      the modes are the same.  */
  1013.       if (TYPE_TRANSPARENT_UNION (type))
  1014.     type = TREE_TYPE (TYPE_FIELDS (type));
  1015.  
  1016.       /* Decide where to pass this arg.
  1017.  
  1018.      args[i].reg is nonzero if all or part is passed in registers.
  1019.  
  1020.      args[i].partial is nonzero if part but not all is passed in registers,
  1021.      and the exact value says how many words are passed in registers.
  1022.  
  1023.      args[i].pass_on_stack is nonzero if the argument must at least be
  1024.      computed on the stack.  It may then be loaded back into registers
  1025.      if args[i].reg is nonzero.
  1026.  
  1027.      These decisions are driven by the FUNCTION_... macros and must agree
  1028.      with those made by function.c.  */
  1029.  
  1030.       /* See if this argument should be passed by invisible reference.  */
  1031.       if ((TREE_CODE (TYPE_SIZE (type)) != INTEGER_CST
  1032.        && contains_placeholder_p (TYPE_SIZE (type)))
  1033.       || TREE_ADDRESSABLE (type)
  1034. #ifdef FUNCTION_ARG_PASS_BY_REFERENCE
  1035.       || FUNCTION_ARG_PASS_BY_REFERENCE (args_so_far, TYPE_MODE (type),
  1036.                          type, argpos < n_named_args)
  1037. #endif
  1038.       )
  1039.     {
  1040. #ifdef FUNCTION_ARG_CALLEE_COPIES
  1041.       if (FUNCTION_ARG_CALLEE_COPIES (args_so_far, TYPE_MODE (type), type,
  1042.                       argpos < n_named_args)
  1043.           /* If it's in a register, we must make a copy of it too.  */
  1044.           /* ??? Is this a sufficient test?  Is there a better one? */
  1045.           && !(TREE_CODE (args[i].tree_value) == VAR_DECL
  1046.            && REG_P (DECL_RTL (args[i].tree_value))))
  1047.         {
  1048.           args[i].tree_value = build1 (ADDR_EXPR,
  1049.                        build_pointer_type (type),
  1050.                        args[i].tree_value);
  1051.           type = build_pointer_type (type);
  1052.         }
  1053.       else
  1054. #endif
  1055.         {
  1056.           /* We make a copy of the object and pass the address to the
  1057.          function being called.  */
  1058.           rtx copy;
  1059.  
  1060.           if (TYPE_SIZE (type) == 0
  1061.           || TREE_CODE (TYPE_SIZE (type)) != INTEGER_CST)
  1062.         {
  1063.           /* This is a variable-sized object.  Make space on the stack
  1064.              for it.  */
  1065.           rtx size_rtx = expr_size (TREE_VALUE (p));
  1066.  
  1067.           if (old_stack_level == 0)
  1068.             {
  1069.               emit_stack_save (SAVE_BLOCK, &old_stack_level, NULL_RTX);
  1070.               old_pending_adj = pending_stack_adjust;
  1071.               pending_stack_adjust = 0;
  1072.             }
  1073.  
  1074.           copy = gen_rtx (MEM, BLKmode,
  1075.                   allocate_dynamic_stack_space (size_rtx,
  1076.                                 NULL_RTX,
  1077.                                 TYPE_ALIGN (type)));
  1078.         }
  1079.           else
  1080.         {
  1081.           int size = int_size_in_bytes (type);
  1082.           copy = assign_stack_temp (TYPE_MODE (type), size, 0);
  1083.         }
  1084.  
  1085.           MEM_IN_STRUCT_P (copy) = AGGREGATE_TYPE_P (type);
  1086.  
  1087.           store_expr (args[i].tree_value, copy, 0);
  1088.  
  1089.           args[i].tree_value = build1 (ADDR_EXPR,
  1090.                        build_pointer_type (type),
  1091.                        make_tree (type, copy));
  1092.           type = build_pointer_type (type);
  1093.         }
  1094.     }
  1095.  
  1096.       mode = TYPE_MODE (type);
  1097.       unsignedp = TREE_UNSIGNED (type);
  1098.  
  1099. #ifdef PROMOTE_FUNCTION_ARGS
  1100.       mode = promote_mode (type, mode, &unsignedp, 1);
  1101. #endif
  1102.  
  1103.       args[i].unsignedp = unsignedp;
  1104.       args[i].mode = mode;
  1105.       args[i].reg = FUNCTION_ARG (args_so_far, mode, type,
  1106.                   argpos < n_named_args);
  1107. #ifdef FUNCTION_ARG_PARTIAL_NREGS
  1108.       if (args[i].reg)
  1109.     args[i].partial
  1110.       = FUNCTION_ARG_PARTIAL_NREGS (args_so_far, mode, type,
  1111.                     argpos < n_named_args);
  1112. #endif
  1113.  
  1114.       args[i].pass_on_stack = MUST_PASS_IN_STACK (mode, type);
  1115.  
  1116.       /* If FUNCTION_ARG returned an (expr_list (nil) FOO), it means that
  1117.      we are to pass this arg in the register(s) designated by FOO, but
  1118.      also to pass it in the stack.  */
  1119.       if (args[i].reg && GET_CODE (args[i].reg) == EXPR_LIST
  1120.       && XEXP (args[i].reg, 0) == 0)
  1121.     args[i].pass_on_stack = 1, args[i].reg = XEXP (args[i].reg, 1);
  1122.  
  1123.       /* If this is an addressable type, we must preallocate the stack
  1124.      since we must evaluate the object into its final location.
  1125.  
  1126.      If this is to be passed in both registers and the stack, it is simpler
  1127.      to preallocate.  */
  1128.       if (TREE_ADDRESSABLE (type)
  1129.       || (args[i].pass_on_stack && args[i].reg != 0))
  1130.     must_preallocate = 1;
  1131.  
  1132.       /* If this is an addressable type, we cannot pre-evaluate it.  Thus,
  1133.      we cannot consider this function call constant.  */
  1134.       if (TREE_ADDRESSABLE (type))
  1135.     is_const = 0;
  1136.  
  1137.       /* Compute the stack-size of this argument.  */
  1138.       if (args[i].reg == 0 || args[i].partial != 0
  1139. #ifdef REG_PARM_STACK_SPACE
  1140.       || reg_parm_stack_space > 0
  1141. #endif
  1142.       || args[i].pass_on_stack)
  1143.     locate_and_pad_parm (mode, type,
  1144. #ifdef STACK_PARMS_IN_REG_PARM_AREA
  1145.                  1,
  1146. #else
  1147.                  args[i].reg != 0,
  1148. #endif
  1149.                  fndecl, &args_size, &args[i].offset,
  1150.                  &args[i].size);
  1151.  
  1152. #ifndef ARGS_GROW_DOWNWARD
  1153.       args[i].slot_offset = args_size;
  1154. #endif
  1155.  
  1156. #ifndef REG_PARM_STACK_SPACE
  1157.       /* If a part of the arg was put into registers,
  1158.      don't include that part in the amount pushed.  */
  1159.       if (! args[i].pass_on_stack)
  1160.     args[i].size.constant -= ((args[i].partial * UNITS_PER_WORD)
  1161.                   / (PARM_BOUNDARY / BITS_PER_UNIT)
  1162.                   * (PARM_BOUNDARY / BITS_PER_UNIT));
  1163. #endif
  1164.       
  1165.       /* Update ARGS_SIZE, the total stack space for args so far.  */
  1166.  
  1167.       args_size.constant += args[i].size.constant;
  1168.       if (args[i].size.var)
  1169.     {
  1170.       ADD_PARM_SIZE (args_size, args[i].size.var);
  1171.     }
  1172.  
  1173.       /* Since the slot offset points to the bottom of the slot,
  1174.      we must record it after incrementing if the args grow down.  */
  1175. #ifdef ARGS_GROW_DOWNWARD
  1176.       args[i].slot_offset = args_size;
  1177.  
  1178.       args[i].slot_offset.constant = -args_size.constant;
  1179.       if (args_size.var)
  1180.     {
  1181.       SUB_PARM_SIZE (args[i].slot_offset, args_size.var);
  1182.     }
  1183. #endif
  1184.  
  1185.       /* Increment ARGS_SO_FAR, which has info about which arg-registers
  1186.      have been used, etc.  */
  1187.  
  1188.       FUNCTION_ARG_ADVANCE (args_so_far, TYPE_MODE (type), type,
  1189.                 argpos < n_named_args);
  1190.     }
  1191.  
  1192. #ifdef FINAL_REG_PARM_STACK_SPACE
  1193.   reg_parm_stack_space = FINAL_REG_PARM_STACK_SPACE (args_size.constant,
  1194.                              args_size.var);
  1195. #endif
  1196.       
  1197.   /* Compute the actual size of the argument block required.  The variable
  1198.      and constant sizes must be combined, the size may have to be rounded,
  1199.      and there may be a minimum required size.  */
  1200.  
  1201.   original_args_size = args_size;
  1202.   if (args_size.var)
  1203.     {
  1204.       /* If this function requires a variable-sized argument list, don't try to
  1205.      make a cse'able block for this call.  We may be able to do this
  1206.      eventually, but it is too complicated to keep track of what insns go
  1207.      in the cse'able block and which don't.  */
  1208.  
  1209.       is_const = 0;
  1210.       must_preallocate = 1;
  1211.  
  1212.       args_size.var = ARGS_SIZE_TREE (args_size);
  1213.       args_size.constant = 0;
  1214.  
  1215. #ifdef STACK_BOUNDARY
  1216.       if (STACK_BOUNDARY != BITS_PER_UNIT)
  1217.     args_size.var = round_up (args_size.var, STACK_BYTES);
  1218. #endif
  1219.  
  1220. #ifdef REG_PARM_STACK_SPACE
  1221.       if (reg_parm_stack_space > 0)
  1222.     {
  1223.       args_size.var
  1224.         = size_binop (MAX_EXPR, args_size.var,
  1225.               size_int (REG_PARM_STACK_SPACE (fndecl)));
  1226.  
  1227. #ifndef OUTGOING_REG_PARM_STACK_SPACE
  1228.       /* The area corresponding to register parameters is not to count in
  1229.          the size of the block we need.  So make the adjustment.  */
  1230.       args_size.var
  1231.         = size_binop (MINUS_EXPR, args_size.var,
  1232.               size_int (reg_parm_stack_space));
  1233. #endif
  1234.     }
  1235. #endif
  1236.     }
  1237.   else
  1238.     {
  1239. #ifdef STACK_BOUNDARY
  1240.       args_size.constant = (((args_size.constant + (STACK_BYTES - 1))
  1241.                  / STACK_BYTES) * STACK_BYTES);
  1242. #endif
  1243.  
  1244. #ifdef REG_PARM_STACK_SPACE
  1245.       args_size.constant = MAX (args_size.constant,
  1246.                 reg_parm_stack_space);
  1247. #ifdef MAYBE_REG_PARM_STACK_SPACE
  1248.       if (reg_parm_stack_space == 0)
  1249.     args_size.constant = 0;
  1250. #endif
  1251. #ifndef OUTGOING_REG_PARM_STACK_SPACE
  1252.       args_size.constant -= reg_parm_stack_space;
  1253. #endif
  1254. #endif
  1255.     }
  1256.  
  1257.   /* See if we have or want to preallocate stack space.
  1258.  
  1259.      If we would have to push a partially-in-regs parm
  1260.      before other stack parms, preallocate stack space instead.
  1261.  
  1262.      If the size of some parm is not a multiple of the required stack
  1263.      alignment, we must preallocate.
  1264.  
  1265.      If the total size of arguments that would otherwise create a copy in
  1266.      a temporary (such as a CALL) is more than half the total argument list
  1267.      size, preallocation is faster.
  1268.  
  1269.      Another reason to preallocate is if we have a machine (like the m88k)
  1270.      where stack alignment is required to be maintained between every
  1271.      pair of insns, not just when the call is made.  However, we assume here
  1272.      that such machines either do not have push insns (and hence preallocation
  1273.      would occur anyway) or the problem is taken care of with
  1274.      PUSH_ROUNDING.  */
  1275.  
  1276.   if (! must_preallocate)
  1277.     {
  1278.       int partial_seen = 0;
  1279.       int copy_to_evaluate_size = 0;
  1280.  
  1281.       for (i = 0; i < num_actuals && ! must_preallocate; i++)
  1282.     {
  1283.       if (args[i].partial > 0 && ! args[i].pass_on_stack)
  1284.         partial_seen = 1;
  1285.       else if (partial_seen && args[i].reg == 0)
  1286.         must_preallocate = 1;
  1287.  
  1288.       if (TYPE_MODE (TREE_TYPE (args[i].tree_value)) == BLKmode
  1289.           && (TREE_CODE (args[i].tree_value) == CALL_EXPR
  1290.           || TREE_CODE (args[i].tree_value) == TARGET_EXPR
  1291.           || TREE_CODE (args[i].tree_value) == COND_EXPR
  1292.           || TREE_ADDRESSABLE (TREE_TYPE (args[i].tree_value))))
  1293.         copy_to_evaluate_size
  1294.           += int_size_in_bytes (TREE_TYPE (args[i].tree_value));
  1295.     }
  1296.  
  1297.       if (copy_to_evaluate_size * 2 >= args_size.constant
  1298.       && args_size.constant > 0)
  1299.     must_preallocate = 1;
  1300.     }
  1301.  
  1302.   /* If the structure value address will reference the stack pointer, we must
  1303.      stabilize it.  We don't need to do this if we know that we are not going
  1304.      to adjust the stack pointer in processing this call.  */
  1305.  
  1306.   if (structure_value_addr
  1307.       && (reg_mentioned_p (virtual_stack_dynamic_rtx, structure_value_addr)
  1308.        || reg_mentioned_p (virtual_outgoing_args_rtx, structure_value_addr))
  1309.       && (args_size.var
  1310. #ifndef ACCUMULATE_OUTGOING_ARGS
  1311.       || args_size.constant
  1312. #endif
  1313.       ))
  1314.     structure_value_addr = copy_to_reg (structure_value_addr);
  1315.  
  1316.   /* If this function call is cse'able, precompute all the parameters.
  1317.      Note that if the parameter is constructed into a temporary, this will
  1318.      cause an additional copy because the parameter will be constructed
  1319.      into a temporary location and then copied into the outgoing arguments.
  1320.      If a parameter contains a call to alloca and this function uses the
  1321.      stack, precompute the parameter.  */
  1322.  
  1323.   /* If we preallocated the stack space, and some arguments must be passed
  1324.      on the stack, then we must precompute any parameter which contains a
  1325.      function call which will store arguments on the stack.
  1326.      Otherwise, evaluating the parameter may clobber previous parameters
  1327.      which have already been stored into the stack.  */
  1328.  
  1329.   for (i = 0; i < num_actuals; i++)
  1330.     if (is_const
  1331.     || ((args_size.var != 0 || args_size.constant != 0)
  1332.         && calls_function (args[i].tree_value, 1))
  1333.     || (must_preallocate && (args_size.var != 0 || args_size.constant != 0)
  1334.         && calls_function (args[i].tree_value, 0)))
  1335.       {
  1336.     /* If this is an addressable type, we cannot pre-evaluate it.  */
  1337.     if (TREE_ADDRESSABLE (TREE_TYPE (args[i].tree_value)))
  1338.       abort ();
  1339.  
  1340.     push_temp_slots ();
  1341.  
  1342.     args[i].initial_value = args[i].value
  1343.       = expand_expr (args[i].tree_value, NULL_RTX, VOIDmode, 0);
  1344.  
  1345.     preserve_temp_slots (args[i].value);
  1346.     pop_temp_slots ();
  1347.  
  1348.     /* ANSI doesn't require a sequence point here,
  1349.        but PCC has one, so this will avoid some problems.  */
  1350.     emit_queue ();
  1351.  
  1352.     args[i].initial_value = args[i].value
  1353.       = protect_from_queue (args[i].initial_value, 0);
  1354.  
  1355.     if (TYPE_MODE (TREE_TYPE (args[i].tree_value)) != args[i].mode)
  1356.       args[i].value
  1357.         = convert_modes (args[i].mode, 
  1358.                  TYPE_MODE (TREE_TYPE (args[i].tree_value)),
  1359.                  args[i].value, args[i].unsignedp);
  1360.       }
  1361.  
  1362.   /* Now we are about to start emitting insns that can be deleted
  1363.      if a libcall is deleted.  */
  1364.   if (is_const)
  1365.     start_sequence ();
  1366.  
  1367.   /* If we have no actual push instructions, or shouldn't use them,
  1368.      make space for all args right now.  */
  1369.  
  1370.   if (args_size.var != 0)
  1371.     {
  1372.       if (old_stack_level == 0)
  1373.     {
  1374.       emit_stack_save (SAVE_BLOCK, &old_stack_level, NULL_RTX);
  1375.       old_pending_adj = pending_stack_adjust;
  1376.       pending_stack_adjust = 0;
  1377. #ifdef ACCUMULATE_OUTGOING_ARGS
  1378.       /* stack_arg_under_construction says whether a stack arg is
  1379.          being constructed at the old stack level.  Pushing the stack
  1380.          gets a clean outgoing argument block.  */
  1381.       old_stack_arg_under_construction = stack_arg_under_construction;
  1382.       stack_arg_under_construction = 0;
  1383. #endif
  1384.     }
  1385.       argblock = push_block (ARGS_SIZE_RTX (args_size), 0, 0);
  1386.     }
  1387.   else
  1388.     {
  1389.       /* Note that we must go through the motions of allocating an argument
  1390.      block even if the size is zero because we may be storing args
  1391.      in the area reserved for register arguments, which may be part of
  1392.      the stack frame.  */
  1393.  
  1394.       int needed = args_size.constant;
  1395.  
  1396.       /* Store the maximum argument space used.  It will be pushed by the
  1397.      prologue (if ACCUMULATE_OUTGOING_ARGS, or stack overflow checking). */
  1398.  
  1399.       if (needed > current_function_outgoing_args_size)
  1400.     current_function_outgoing_args_size = needed;
  1401.  
  1402.       if (must_preallocate)
  1403.     {
  1404. #ifdef ACCUMULATE_OUTGOING_ARGS
  1405.       /* Since the stack pointer will never be pushed, it is possible for
  1406.          the evaluation of a parm to clobber something we have already
  1407.          written to the stack.  Since most function calls on RISC machines
  1408.          do not use the stack, this is uncommon, but must work correctly.
  1409.  
  1410.          Therefore, we save any area of the stack that was already written
  1411.          and that we are using.  Here we set up to do this by making a new
  1412.          stack usage map from the old one.  The actual save will be done
  1413.          by store_one_arg. 
  1414.  
  1415.          Another approach might be to try to reorder the argument
  1416.          evaluations to avoid this conflicting stack usage.  */
  1417.  
  1418. #if defined(REG_PARM_STACK_SPACE) && ! defined(OUTGOING_REG_PARM_STACK_SPACE)
  1419.       /* Since we will be writing into the entire argument area, the
  1420.          map must be allocated for its entire size, not just the part that
  1421.          is the responsibility of the caller.  */
  1422.       needed += reg_parm_stack_space;
  1423. #endif
  1424.  
  1425. #ifdef ARGS_GROW_DOWNWARD
  1426.       highest_outgoing_arg_in_use = MAX (initial_highest_arg_in_use,
  1427.                          needed + 1);
  1428. #else
  1429.       highest_outgoing_arg_in_use = MAX (initial_highest_arg_in_use,
  1430.                          needed);
  1431. #endif
  1432.       stack_usage_map = (char *) alloca (highest_outgoing_arg_in_use);
  1433.  
  1434.       if (initial_highest_arg_in_use)
  1435.         bcopy (initial_stack_usage_map, stack_usage_map,
  1436.            initial_highest_arg_in_use);
  1437.  
  1438.       if (initial_highest_arg_in_use != highest_outgoing_arg_in_use)
  1439.         bzero (&stack_usage_map[initial_highest_arg_in_use],
  1440.            highest_outgoing_arg_in_use - initial_highest_arg_in_use);
  1441.       needed = 0;
  1442.  
  1443.       /* The address of the outgoing argument list must not be copied to a
  1444.          register here, because argblock would be left pointing to the
  1445.          wrong place after the call to allocate_dynamic_stack_space below.
  1446.          */
  1447.  
  1448.       argblock = virtual_outgoing_args_rtx;
  1449.  
  1450. #else /* not ACCUMULATE_OUTGOING_ARGS */
  1451.       if (inhibit_defer_pop == 0)
  1452.         {
  1453.           /* Try to reuse some or all of the pending_stack_adjust
  1454.          to get this space.  Maybe we can avoid any pushing.  */
  1455.           if (needed > pending_stack_adjust)
  1456.         {
  1457.           needed -= pending_stack_adjust;
  1458.           pending_stack_adjust = 0;
  1459.         }
  1460.           else
  1461.         {
  1462.           pending_stack_adjust -= needed;
  1463.           needed = 0;
  1464.         }
  1465.         }
  1466.       /* Special case this because overhead of `push_block' in this
  1467.          case is non-trivial.  */
  1468.       if (needed == 0)
  1469.         argblock = virtual_outgoing_args_rtx;
  1470.       else
  1471.         argblock = push_block (GEN_INT (needed), 0, 0);
  1472.  
  1473.       /* We only really need to call `copy_to_reg' in the case where push
  1474.          insns are going to be used to pass ARGBLOCK to a function
  1475.          call in ARGS.  In that case, the stack pointer changes value
  1476.          from the allocation point to the call point, and hence
  1477.          the value of VIRTUAL_OUTGOING_ARGS_RTX changes as well.
  1478.          But might as well always do it.  */
  1479.       argblock = copy_to_reg (argblock);
  1480. #endif /* not ACCUMULATE_OUTGOING_ARGS */
  1481.     }
  1482.     }
  1483.  
  1484. #ifdef ACCUMULATE_OUTGOING_ARGS
  1485.   /* The save/restore code in store_one_arg handles all cases except one:
  1486.      a constructor call (including a C function returning a BLKmode struct)
  1487.      to initialize an argument.  */
  1488.   if (stack_arg_under_construction)
  1489.     {
  1490. #if defined(REG_PARM_STACK_SPACE) && ! defined(OUTGOING_REG_PARM_STACK_SPACE)
  1491.       rtx push_size = GEN_INT (reg_parm_stack_space + args_size.constant);
  1492. #else
  1493.       rtx push_size = GEN_INT (args_size.constant);
  1494. #endif
  1495.       if (old_stack_level == 0)
  1496.     {
  1497.       emit_stack_save (SAVE_BLOCK, &old_stack_level, NULL_RTX);
  1498.       old_pending_adj = pending_stack_adjust;
  1499.       pending_stack_adjust = 0;
  1500.       /* stack_arg_under_construction says whether a stack arg is
  1501.          being constructed at the old stack level.  Pushing the stack
  1502.          gets a clean outgoing argument block.  */
  1503.       old_stack_arg_under_construction = stack_arg_under_construction;
  1504.       stack_arg_under_construction = 0;
  1505.       /* Make a new map for the new argument list.  */
  1506.       stack_usage_map = (char *)alloca (highest_outgoing_arg_in_use);
  1507.       bzero (stack_usage_map, highest_outgoing_arg_in_use);
  1508.       highest_outgoing_arg_in_use = 0;
  1509.     }
  1510.       allocate_dynamic_stack_space (push_size, NULL_RTX, BITS_PER_UNIT);
  1511.     }
  1512.   /* If argument evaluation might modify the stack pointer, copy the
  1513.      address of the argument list to a register.  */
  1514.   for (i = 0; i < num_actuals; i++)
  1515.     if (args[i].pass_on_stack)
  1516.       {
  1517.     argblock = copy_addr_to_reg (argblock);
  1518.     break;
  1519.       }
  1520. #endif
  1521.  
  1522.  
  1523.   /* If we preallocated stack space, compute the address of each argument.
  1524.      We need not ensure it is a valid memory address here; it will be 
  1525.      validized when it is used.  */
  1526.   if (argblock)
  1527.     {
  1528.       rtx arg_reg = argblock;
  1529.       int arg_offset = 0;
  1530.  
  1531.       if (GET_CODE (argblock) == PLUS)
  1532.     arg_reg = XEXP (argblock, 0), arg_offset = INTVAL (XEXP (argblock, 1));
  1533.  
  1534.       for (i = 0; i < num_actuals; i++)
  1535.     {
  1536.       rtx offset = ARGS_SIZE_RTX (args[i].offset);
  1537.       rtx slot_offset = ARGS_SIZE_RTX (args[i].slot_offset);
  1538.       rtx addr;
  1539.  
  1540.       /* Skip this parm if it will not be passed on the stack.  */
  1541.       if (! args[i].pass_on_stack && args[i].reg != 0)
  1542.         continue;
  1543.  
  1544.       if (GET_CODE (offset) == CONST_INT)
  1545.         addr = plus_constant (arg_reg, INTVAL (offset));
  1546.       else
  1547.         addr = gen_rtx (PLUS, Pmode, arg_reg, offset);
  1548.  
  1549.       addr = plus_constant (addr, arg_offset);
  1550.       args[i].stack = gen_rtx (MEM, args[i].mode, addr);
  1551.       MEM_IN_STRUCT_P (args[i].stack)
  1552.         = AGGREGATE_TYPE_P (TREE_TYPE (args[i].tree_value));
  1553.  
  1554.       if (GET_CODE (slot_offset) == CONST_INT)
  1555.         addr = plus_constant (arg_reg, INTVAL (slot_offset));
  1556.       else
  1557.         addr = gen_rtx (PLUS, Pmode, arg_reg, slot_offset);
  1558.  
  1559.       addr = plus_constant (addr, arg_offset);
  1560.       args[i].stack_slot = gen_rtx (MEM, args[i].mode, addr);
  1561.     }
  1562.     }
  1563.                            
  1564. #ifdef PUSH_ARGS_REVERSED
  1565. #ifdef STACK_BOUNDARY
  1566.   /* If we push args individually in reverse order, perform stack alignment
  1567.      before the first push (the last arg).  */
  1568.   if (argblock == 0)
  1569.     anti_adjust_stack (GEN_INT (args_size.constant
  1570.                 - original_args_size.constant));
  1571. #endif
  1572. #endif
  1573.  
  1574.   /* Don't try to defer pops if preallocating, not even from the first arg,
  1575.      since ARGBLOCK probably refers to the SP.  */
  1576.   if (argblock)
  1577.     NO_DEFER_POP;
  1578.  
  1579.   /* Get the function to call, in the form of RTL.  */
  1580.   if (fndecl)
  1581.     {
  1582.       /* If this is the first use of the function, see if we need to
  1583.      make an external definition for it.  */
  1584.       if (! TREE_USED (fndecl))
  1585.     {
  1586.       assemble_external (fndecl);
  1587.       TREE_USED (fndecl) = 1;
  1588.     }
  1589.  
  1590.       /* Get a SYMBOL_REF rtx for the function address.  */
  1591.       funexp = XEXP (DECL_RTL (fndecl), 0);
  1592.     }
  1593.   else
  1594.     /* Generate an rtx (probably a pseudo-register) for the address.  */
  1595.     {
  1596.       push_temp_slots ();
  1597.       funexp = expand_expr (TREE_OPERAND (exp, 0), NULL_RTX, VOIDmode, 0);
  1598.       pop_temp_slots ();    /* FUNEXP can't be BLKmode */
  1599.       emit_queue ();
  1600.     }
  1601.  
  1602.   /* Figure out the register where the value, if any, will come back.  */
  1603.   valreg = 0;
  1604.   if (TYPE_MODE (TREE_TYPE (exp)) != VOIDmode
  1605.       && ! structure_value_addr)
  1606.     {
  1607.       if (pcc_struct_value)
  1608.     valreg = hard_function_value (build_pointer_type (TREE_TYPE (exp)),
  1609.                       fndecl);
  1610.       else
  1611.     valreg = hard_function_value (TREE_TYPE (exp), fndecl);
  1612.     }
  1613.  
  1614.   /* Precompute all register parameters.  It isn't safe to compute anything
  1615.      once we have started filling any specific hard regs. */
  1616.   reg_parm_seen = 0;
  1617.   for (i = 0; i < num_actuals; i++)
  1618.     if (args[i].reg != 0 && ! args[i].pass_on_stack)
  1619.       {
  1620.     reg_parm_seen = 1;
  1621.  
  1622.     if (args[i].value == 0)
  1623.       {
  1624.         push_temp_slots ();
  1625.         args[i].value = expand_expr (args[i].tree_value, NULL_RTX,
  1626.                      VOIDmode, 0);
  1627.         preserve_temp_slots (args[i].value);
  1628.         pop_temp_slots ();
  1629.  
  1630.         /* ANSI doesn't require a sequence point here,
  1631.            but PCC has one, so this will avoid some problems.  */
  1632.         emit_queue ();
  1633.       }
  1634.  
  1635.     /* If we are to promote the function arg to a wider mode,
  1636.        do it now.  */
  1637.  
  1638.     if (args[i].mode != TYPE_MODE (TREE_TYPE (args[i].tree_value)))
  1639.       args[i].value
  1640.         = convert_modes (args[i].mode,
  1641.                  TYPE_MODE (TREE_TYPE (args[i].tree_value)),
  1642.                  args[i].value, args[i].unsignedp);
  1643.  
  1644.     /* If the value is expensive, and we are inside an appropriately 
  1645.        short loop, put the value into a pseudo and then put the pseudo
  1646.        into the hard reg.
  1647.  
  1648.        For small register classes, also do this if this call uses
  1649.        register parameters.  This is to avoid reload conflicts while
  1650.        loading the parameters registers.  */
  1651.  
  1652.     if ((! (GET_CODE (args[i].value) == REG
  1653.         || (GET_CODE (args[i].value) == SUBREG
  1654.             && GET_CODE (SUBREG_REG (args[i].value)) == REG)))
  1655.         && args[i].mode != BLKmode
  1656.         && rtx_cost (args[i].value, SET) > 2
  1657. #ifdef SMALL_REGISTER_CLASSES
  1658.         && (reg_parm_seen || preserve_subexpressions_p ())
  1659. #else
  1660.         && preserve_subexpressions_p ()
  1661. #endif
  1662.         )
  1663.       args[i].value = copy_to_mode_reg (args[i].mode, args[i].value);
  1664.       }
  1665.  
  1666. #if defined(ACCUMULATE_OUTGOING_ARGS) && defined(REG_PARM_STACK_SPACE)
  1667.   /* The argument list is the property of the called routine and it
  1668.      may clobber it.  If the fixed area has been used for previous
  1669.      parameters, we must save and restore it.
  1670.  
  1671.      Here we compute the boundary of the that needs to be saved, if any.  */
  1672.  
  1673. #ifdef ARGS_GROW_DOWNWARD
  1674.   for (i = 0; i < reg_parm_stack_space + 1; i++)
  1675. #else
  1676.   for (i = 0; i < reg_parm_stack_space; i++)
  1677. #endif
  1678.     {
  1679.       if (i >=  highest_outgoing_arg_in_use
  1680.       || stack_usage_map[i] == 0)
  1681.     continue;
  1682.  
  1683.       if (low_to_save == -1)
  1684.     low_to_save = i;
  1685.  
  1686.       high_to_save = i;
  1687.     }
  1688.  
  1689.   if (low_to_save >= 0)
  1690.     {
  1691.       int num_to_save = high_to_save - low_to_save + 1;
  1692.       enum machine_mode save_mode
  1693.     = mode_for_size (num_to_save * BITS_PER_UNIT, MODE_INT, 1);
  1694.       rtx stack_area;
  1695.  
  1696.       /* If we don't have the required alignment, must do this in BLKmode.  */
  1697.       if ((low_to_save & (MIN (GET_MODE_SIZE (save_mode),
  1698.                    BIGGEST_ALIGNMENT / UNITS_PER_WORD) - 1)))
  1699.     save_mode = BLKmode;
  1700.  
  1701.       stack_area = gen_rtx (MEM, save_mode,
  1702.                 memory_address (save_mode,
  1703.                         
  1704. #ifdef ARGS_GROW_DOWNWARD
  1705.                         plus_constant (argblock,
  1706.                                - high_to_save)
  1707. #else
  1708.                         plus_constant (argblock,
  1709.                                low_to_save)
  1710. #endif
  1711.                         ));
  1712.       if (save_mode == BLKmode)
  1713.     {
  1714.       save_area = assign_stack_temp (BLKmode, num_to_save, 0);
  1715.       MEM_IN_STRUCT_P (save_area) = 0;
  1716.       emit_block_move (validize_mem (save_area), stack_area,
  1717.                GEN_INT (num_to_save),
  1718.                PARM_BOUNDARY / BITS_PER_UNIT);
  1719.     }
  1720.       else
  1721.     {
  1722.       save_area = gen_reg_rtx (save_mode);
  1723.       emit_move_insn (save_area, stack_area);
  1724.     }
  1725.     }
  1726. #endif
  1727.       
  1728.  
  1729.   /* Now store (and compute if necessary) all non-register parms.
  1730.      These come before register parms, since they can require block-moves,
  1731.      which could clobber the registers used for register parms.
  1732.      Parms which have partial registers are not stored here,
  1733.      but we do preallocate space here if they want that.  */
  1734.  
  1735.   for (i = 0; i < num_actuals; i++)
  1736.     if (args[i].reg == 0 || args[i].pass_on_stack)
  1737.       store_one_arg (&args[i], argblock, may_be_alloca,
  1738.              args_size.var != 0, fndecl, reg_parm_stack_space);
  1739.  
  1740. #ifdef STRICT_ALIGNMENT
  1741.   /* If we have a parm that is passed in registers but not in memory
  1742.      and whose alignment does not permit a direct copy into registers,
  1743.      make a group of pseudos that correspond to each register that we
  1744.      will later fill.  */
  1745.  
  1746.   for (i = 0; i < num_actuals; i++)
  1747.     if (args[i].reg != 0 && ! args[i].pass_on_stack
  1748.     && args[i].mode == BLKmode
  1749.     && (TYPE_ALIGN (TREE_TYPE (args[i].tree_value))
  1750.         < MIN (BIGGEST_ALIGNMENT, BITS_PER_WORD)))
  1751.       {
  1752.     int bytes = int_size_in_bytes (TREE_TYPE (args[i].tree_value));
  1753.     int big_endian_correction = 0;
  1754.  
  1755.     args[i].n_aligned_regs
  1756.       = args[i].partial ? args[i].partial
  1757.         : (bytes + (UNITS_PER_WORD - 1)) / UNITS_PER_WORD;
  1758.  
  1759.     args[i].aligned_regs = (rtx *) alloca (sizeof (rtx)
  1760.                            * args[i].n_aligned_regs);
  1761.  
  1762.     /* Structures smaller than a word are aligned to the least significant
  1763.        byte (to the right).  On a BYTES_BIG_ENDIAN machine, this means we
  1764.        must skip the empty high order bytes when calculating the bit
  1765.        offset.  */
  1766.     if (BYTES_BIG_ENDIAN && bytes < UNITS_PER_WORD)
  1767.       big_endian_correction = (BITS_PER_WORD  - (bytes * BITS_PER_UNIT));
  1768.  
  1769.     for (j = 0; j < args[i].n_aligned_regs; j++)
  1770.       {
  1771.         rtx reg = gen_reg_rtx (word_mode);
  1772.         rtx word = operand_subword_force (args[i].value, j, BLKmode);
  1773.         int bitsize = TYPE_ALIGN (TREE_TYPE (args[i].tree_value));
  1774.         int bitpos;
  1775.  
  1776.         args[i].aligned_regs[j] = reg;
  1777.  
  1778.         /* Clobber REG and move each partword into it.  Ensure we don't
  1779.            go past the end of the structure.  Note that the loop below
  1780.            works because we've already verified that padding
  1781.            and endianness are compatible.  */
  1782.  
  1783.         emit_insn (gen_rtx (CLOBBER, VOIDmode, reg));
  1784.  
  1785.         for (bitpos = 0;
  1786.          bitpos < BITS_PER_WORD && bytes > 0;
  1787.          bitpos += bitsize, bytes -= bitsize / BITS_PER_UNIT)
  1788.           {
  1789.         int xbitpos = bitpos + big_endian_correction;
  1790.  
  1791.         store_bit_field (reg, bitsize, xbitpos, word_mode,
  1792.                  extract_bit_field (word, bitsize, bitpos, 1,
  1793.                             NULL_RTX, word_mode,
  1794.                             word_mode,
  1795.                             bitsize / BITS_PER_UNIT,
  1796.                             BITS_PER_WORD),
  1797.                  bitsize / BITS_PER_UNIT, BITS_PER_WORD);
  1798.           }
  1799.       }
  1800.       }
  1801. #endif
  1802.  
  1803.   /* Now store any partially-in-registers parm.
  1804.      This is the last place a block-move can happen.  */
  1805.   if (reg_parm_seen)
  1806.     for (i = 0; i < num_actuals; i++)
  1807.       if (args[i].partial != 0 && ! args[i].pass_on_stack)
  1808.     store_one_arg (&args[i], argblock, may_be_alloca,
  1809.                args_size.var != 0, fndecl, reg_parm_stack_space);
  1810.  
  1811. #ifndef PUSH_ARGS_REVERSED
  1812. #ifdef STACK_BOUNDARY
  1813.   /* If we pushed args in forward order, perform stack alignment
  1814.      after pushing the last arg.  */
  1815.   if (argblock == 0)
  1816.     anti_adjust_stack (GEN_INT (args_size.constant
  1817.                 - original_args_size.constant));
  1818. #endif
  1819. #endif
  1820.  
  1821.   /* If register arguments require space on the stack and stack space
  1822.      was not preallocated, allocate stack space here for arguments
  1823.      passed in registers.  */
  1824. #if ! defined(ACCUMULATE_OUTGOING_ARGS) && defined(OUTGOING_REG_PARM_STACK_SPACE)
  1825.   if (must_preallocate == 0 && reg_parm_stack_space > 0)
  1826.     anti_adjust_stack (GEN_INT (reg_parm_stack_space));
  1827. #endif
  1828.  
  1829.   /* Pass the function the address in which to return a structure value.  */
  1830.   if (structure_value_addr && ! structure_value_addr_parm)
  1831.     {
  1832.       emit_move_insn (struct_value_rtx,
  1833.               force_reg (Pmode,
  1834.                  force_operand (structure_value_addr,
  1835.                         NULL_RTX)));
  1836.       if (GET_CODE (struct_value_rtx) == REG)
  1837.       use_reg (&call_fusage, struct_value_rtx);
  1838.     }
  1839.  
  1840.   funexp = prepare_call_address (funexp, fndecl, &call_fusage, reg_parm_seen);
  1841.  
  1842.   /* Now do the register loads required for any wholly-register parms or any
  1843.      parms which are passed both on the stack and in a register.  Their
  1844.      expressions were already evaluated. 
  1845.  
  1846.      Mark all register-parms as living through the call, putting these USE
  1847.      insns in the CALL_INSN_FUNCTION_USAGE field.  */
  1848.  
  1849.   for (i = 0; i < num_actuals; i++)
  1850.     {
  1851.       rtx list = args[i].reg;
  1852.       int partial = args[i].partial;
  1853.  
  1854.       while (list)
  1855.     {
  1856.       rtx reg;
  1857.       int nregs;
  1858.  
  1859.       /* Process each register that needs to get this arg.  */
  1860.       if (GET_CODE (list) == EXPR_LIST)
  1861.         reg = XEXP (list, 0), list = XEXP (list, 1);
  1862.       else
  1863.         reg = list, list = 0;
  1864.  
  1865.       /* Set to non-negative if must move a word at a time, even if just
  1866.          one word (e.g, partial == 1 && mode == DFmode).  Set to -1 if
  1867.          we just use a normal move insn.  This value can be zero if the
  1868.          argument is a zero size structure with no fields.  */
  1869.       nregs = (partial ? partial
  1870.            : (TYPE_MODE (TREE_TYPE (args[i].tree_value)) == BLKmode
  1871.               ? ((int_size_in_bytes (TREE_TYPE (args[i].tree_value))
  1872.               + (UNITS_PER_WORD - 1)) / UNITS_PER_WORD)
  1873.               : -1));
  1874.  
  1875.       /* If simple case, just do move.  If normal partial, store_one_arg
  1876.          has already loaded the register for us.  In all other cases,
  1877.          load the register(s) from memory.  */
  1878.  
  1879.       if (nregs == -1)
  1880.         emit_move_insn (reg, args[i].value);
  1881.  
  1882. #ifdef STRICT_ALIGNMENT
  1883.       /* If we have pre-computed the values to put in the registers in
  1884.          the case of non-aligned structures, copy them in now.  */
  1885.  
  1886.       else if (args[i].n_aligned_regs != 0)
  1887.         for (j = 0; j < args[i].n_aligned_regs; j++)
  1888.           emit_move_insn (gen_rtx (REG, word_mode, REGNO (reg) + j),
  1889.                   args[i].aligned_regs[j]);
  1890. #endif
  1891.  
  1892.       else if (args[i].partial == 0 || args[i].pass_on_stack)
  1893.         move_block_to_reg (REGNO (reg),
  1894.                    validize_mem (args[i].value), nregs,
  1895.                    args[i].mode);
  1896.  
  1897.       if (nregs == -1)
  1898.         use_reg (&call_fusage, reg);
  1899.       else
  1900.         use_regs (&call_fusage, REGNO (reg), nregs == 0 ? 1 : nregs);
  1901.  
  1902.       /* PARTIAL referred only to the first register, so clear it for the
  1903.          next time.  */
  1904.       partial = 0;
  1905.     }
  1906.     }
  1907.  
  1908.   /* Perform postincrements before actually calling the function.  */
  1909.   emit_queue ();
  1910.  
  1911.   /* All arguments and registers used for the call must be set up by now!  */
  1912.  
  1913.   /* Generate the actual call instruction.  */
  1914.   emit_call_1 (funexp, fndecl, funtype, args_size.constant, struct_value_size,
  1915.            FUNCTION_ARG (args_so_far, VOIDmode, void_type_node, 1),
  1916.            valreg, old_inhibit_defer_pop, call_fusage, is_const);
  1917.  
  1918.   /* If call is cse'able, make appropriate pair of reg-notes around it.
  1919.      Test valreg so we don't crash; may safely ignore `const'
  1920.      if return type is void.  */
  1921.   if (is_const && valreg != 0)
  1922.     {
  1923.       rtx note = 0;
  1924.       rtx temp = gen_reg_rtx (GET_MODE (valreg));
  1925.       rtx insns;
  1926.  
  1927.       /* Construct an "equal form" for the value which mentions all the
  1928.      arguments in order as well as the function name.  */
  1929. #ifdef PUSH_ARGS_REVERSED
  1930.       for (i = 0; i < num_actuals; i++)
  1931.     note = gen_rtx (EXPR_LIST, VOIDmode, args[i].initial_value, note);
  1932. #else
  1933.       for (i = num_actuals - 1; i >= 0; i--)
  1934.     note = gen_rtx (EXPR_LIST, VOIDmode, args[i].initial_value, note);
  1935. #endif
  1936.       note = gen_rtx (EXPR_LIST, VOIDmode, funexp, note);
  1937.  
  1938.       insns = get_insns ();
  1939.       end_sequence ();
  1940.  
  1941.       emit_libcall_block (insns, temp, valreg, note);
  1942.  
  1943.       valreg = temp;
  1944.     }
  1945.   else if (is_const)
  1946.     {
  1947.       /* Otherwise, just write out the sequence without a note.  */
  1948.       rtx insns = get_insns ();
  1949.  
  1950.       end_sequence ();
  1951.       emit_insns (insns);
  1952.     }
  1953.  
  1954.   /* For calls to `setjmp', etc., inform flow.c it should complain
  1955.      if nonvolatile values are live.  */
  1956.  
  1957.   if (returns_twice)
  1958.     {
  1959.       emit_note (name, NOTE_INSN_SETJMP);
  1960.       current_function_calls_setjmp = 1;
  1961.     }
  1962.  
  1963.   if (is_longjmp)
  1964.     current_function_calls_longjmp = 1;
  1965.  
  1966.   /* Notice functions that cannot return.
  1967.      If optimizing, insns emitted below will be dead.
  1968.      If not optimizing, they will exist, which is useful
  1969.      if the user uses the `return' command in the debugger.  */
  1970.  
  1971.   if (is_volatile || is_longjmp)
  1972.     emit_barrier ();
  1973.  
  1974.   /* If value type not void, return an rtx for the value.  */
  1975.  
  1976.   /* If there are cleanups to be called, don't use a hard reg as target.  */
  1977.   if (cleanups_this_call != old_cleanups
  1978.       && target && REG_P (target)
  1979.       && REGNO (target) < FIRST_PSEUDO_REGISTER)
  1980.     target = 0;
  1981.  
  1982.   if (TYPE_MODE (TREE_TYPE (exp)) == VOIDmode
  1983.       || ignore)
  1984.     {
  1985.       target = const0_rtx;
  1986.     }
  1987.   else if (structure_value_addr)
  1988.     {
  1989.       if (target == 0 || GET_CODE (target) != MEM)
  1990.     {
  1991.       target = gen_rtx (MEM, TYPE_MODE (TREE_TYPE (exp)),
  1992.                 memory_address (TYPE_MODE (TREE_TYPE (exp)),
  1993.                         structure_value_addr));
  1994.       MEM_IN_STRUCT_P (target) = AGGREGATE_TYPE_P (TREE_TYPE (exp));
  1995.     }
  1996.     }
  1997.   else if (pcc_struct_value)
  1998.     {
  1999.       if (target == 0)
  2000.     {
  2001.       /* We used leave the value in the location that it is
  2002.          returned in, but that causes problems if it is used more
  2003.          than once in one expression.  Rather than trying to track
  2004.          when a copy is required, we always copy when TARGET is
  2005.          not specified.  This calling sequence is only used on
  2006.          a few machines and TARGET is usually nonzero.  */
  2007.       if (TYPE_MODE (TREE_TYPE (exp)) == BLKmode)
  2008.         {
  2009.           target = assign_stack_temp (BLKmode,
  2010.                       int_size_in_bytes (TREE_TYPE (exp)),
  2011.                       0);
  2012.  
  2013.           MEM_IN_STRUCT_P (target) = AGGREGATE_TYPE_P (TREE_TYPE (exp));
  2014.  
  2015.           /* Save this temp slot around the pop below.  */
  2016.           preserve_temp_slots (target);
  2017.         }
  2018.       else
  2019.         target = gen_reg_rtx (TYPE_MODE (TREE_TYPE (exp)));
  2020.     }
  2021.  
  2022.       if (TYPE_MODE (TREE_TYPE (exp)) != BLKmode)
  2023.     emit_move_insn (target, gen_rtx (MEM, TYPE_MODE (TREE_TYPE (exp)),
  2024.                      copy_to_reg (valreg)));
  2025.       else
  2026.     emit_block_move (target, gen_rtx (MEM, BLKmode, copy_to_reg (valreg)),
  2027.              expr_size (exp),
  2028.              TYPE_ALIGN (TREE_TYPE (exp)) / BITS_PER_UNIT);
  2029.     }
  2030.   else if (target && GET_MODE (target) == TYPE_MODE (TREE_TYPE (exp))
  2031.        && GET_MODE (target) == GET_MODE (valreg))
  2032.     /* TARGET and VALREG cannot be equal at this point because the latter
  2033.        would not have REG_FUNCTION_VALUE_P true, while the former would if
  2034.        it were referring to the same register.
  2035.  
  2036.        If they refer to the same register, this move will be a no-op, except
  2037.        when function inlining is being done.  */
  2038.     emit_move_insn (target, valreg);
  2039.   else if (TYPE_MODE (TREE_TYPE (exp)) == BLKmode)
  2040.     {
  2041.       /* Some machines (the PA for example) want to return all small
  2042.      structures in registers regardless of the structure's alignment.
  2043.      
  2044.      Deal with them explicitly by copying from the return registers
  2045.      into the target MEM locations.  */
  2046.       int bytes = int_size_in_bytes (TREE_TYPE (exp));
  2047.       int n_regs = (bytes + UNITS_PER_WORD - 1) / UNITS_PER_WORD;
  2048.       int i;
  2049.       enum machine_mode tmpmode;
  2050.       
  2051.       if (target == 0)
  2052.     {
  2053.       target = assign_stack_temp (BLKmode, bytes, 0);
  2054.       MEM_IN_STRUCT_P (target) = AGGREGATE_TYPE_P (TREE_TYPE (exp));
  2055.       preserve_temp_slots (target);
  2056.     }
  2057.  
  2058.       /* We could probably emit more efficient code for machines
  2059.      which do not use strict alignment, but it doesn't seem
  2060.      worth the effort at the current time.  */
  2061.       for (i = 0; i < n_regs; i++)
  2062.     {
  2063.       rtx src = operand_subword_force (valreg, i, BLKmode);
  2064.       rtx dst = operand_subword (target, i, 1, BLKmode);
  2065.       int bitsize = MIN (TYPE_ALIGN (TREE_TYPE (exp)), BITS_PER_WORD);
  2066.       int bitpos, big_endian_correction = 0;
  2067.       
  2068.       /* Should never happen.  */
  2069.       if (src == NULL || dst == NULL)
  2070.         abort ();
  2071.       
  2072.       if (BYTES_BIG_ENDIAN && bytes < UNITS_PER_WORD)
  2073.         big_endian_correction
  2074.           = (BITS_PER_WORD - (bytes * BITS_PER_UNIT));
  2075.       
  2076.       for (bitpos = 0;
  2077.            bitpos < BITS_PER_WORD && bytes > 0;
  2078.            bitpos += bitsize, bytes -= bitsize / BITS_PER_UNIT)
  2079.         {
  2080.           int xbitpos = bitpos + big_endian_correction;
  2081.           
  2082.           store_bit_field (dst, bitsize, xbitpos, word_mode,
  2083.                    extract_bit_field (src, bitsize, bitpos, 1,
  2084.                           NULL_RTX, word_mode,
  2085.                           word_mode,
  2086.                           bitsize / BITS_PER_UNIT,
  2087.                           BITS_PER_WORD),
  2088.                    bitsize / BITS_PER_UNIT, BITS_PER_WORD);
  2089.         }
  2090.     }
  2091.     }
  2092.   else
  2093.     target = copy_to_reg (valreg);
  2094.  
  2095. #ifdef PROMOTE_FUNCTION_RETURN
  2096.   /* If we promoted this return value, make the proper SUBREG.  TARGET
  2097.      might be const0_rtx here, so be careful.  */
  2098.   if (GET_CODE (target) == REG
  2099.       && TYPE_MODE (TREE_TYPE (exp)) != BLKmode
  2100.       && GET_MODE (target) != TYPE_MODE (TREE_TYPE (exp)))
  2101.     {
  2102.       tree type = TREE_TYPE (exp);
  2103.       int unsignedp = TREE_UNSIGNED (type);
  2104.  
  2105.       /* If we don't promote as expected, something is wrong.  */
  2106.       if (GET_MODE (target)
  2107.       != promote_mode (type, TYPE_MODE (type), &unsignedp, 1))
  2108.     abort ();
  2109.  
  2110.       target = gen_rtx (SUBREG, TYPE_MODE (type), target, 0);
  2111.       SUBREG_PROMOTED_VAR_P (target) = 1;
  2112.       SUBREG_PROMOTED_UNSIGNED_P (target) = unsignedp;
  2113.     }
  2114. #endif
  2115.  
  2116.   if (flag_short_temps)
  2117.     {
  2118.       /* Perform all cleanups needed for the arguments of this call
  2119.      (i.e. destructors in C++).  */
  2120.       expand_cleanups_to (old_cleanups);
  2121.     }
  2122.  
  2123.   /* If size of args is variable or this was a constructor call for a stack
  2124.      argument, restore saved stack-pointer value.  */
  2125.  
  2126.   if (old_stack_level)
  2127.     {
  2128.       emit_stack_restore (SAVE_BLOCK, old_stack_level, NULL_RTX);
  2129.       pending_stack_adjust = old_pending_adj;
  2130. #ifdef ACCUMULATE_OUTGOING_ARGS
  2131.       stack_arg_under_construction = old_stack_arg_under_construction;
  2132.       highest_outgoing_arg_in_use = initial_highest_arg_in_use;
  2133.       stack_usage_map = initial_stack_usage_map;
  2134. #endif
  2135.     }
  2136. #ifdef ACCUMULATE_OUTGOING_ARGS
  2137.   else
  2138.     {
  2139. #ifdef REG_PARM_STACK_SPACE
  2140.       if (save_area)
  2141.     {
  2142.       enum machine_mode save_mode = GET_MODE (save_area);
  2143.       rtx stack_area
  2144.         = gen_rtx (MEM, save_mode,
  2145.                memory_address (save_mode,
  2146. #ifdef ARGS_GROW_DOWNWARD
  2147.                        plus_constant (argblock, - high_to_save)
  2148. #else
  2149.                        plus_constant (argblock, low_to_save)
  2150. #endif
  2151.                        ));
  2152.  
  2153.       if (save_mode != BLKmode)
  2154.         emit_move_insn (stack_area, save_area);
  2155.       else
  2156.         emit_block_move (stack_area, validize_mem (save_area),
  2157.                  GEN_INT (high_to_save - low_to_save + 1),
  2158.                  PARM_BOUNDARY / BITS_PER_UNIT);
  2159.     }
  2160. #endif
  2161.       
  2162.       /* If we saved any argument areas, restore them.  */
  2163.       for (i = 0; i < num_actuals; i++)
  2164.     if (args[i].save_area)
  2165.       {
  2166.         enum machine_mode save_mode = GET_MODE (args[i].save_area);
  2167.         rtx stack_area
  2168.           = gen_rtx (MEM, save_mode,
  2169.              memory_address (save_mode,
  2170.                      XEXP (args[i].stack_slot, 0)));
  2171.  
  2172.         if (save_mode != BLKmode)
  2173.           emit_move_insn (stack_area, args[i].save_area);
  2174.         else
  2175.           emit_block_move (stack_area, validize_mem (args[i].save_area),
  2176.                    GEN_INT (args[i].size.constant),
  2177.                    PARM_BOUNDARY / BITS_PER_UNIT);
  2178.       }
  2179.  
  2180.       highest_outgoing_arg_in_use = initial_highest_arg_in_use;
  2181.       stack_usage_map = initial_stack_usage_map;
  2182.     }
  2183. #endif
  2184.  
  2185.   /* If this was alloca, record the new stack level for nonlocal gotos.  
  2186.      Check for the handler slots since we might not have a save area
  2187.      for non-local gotos. */
  2188.  
  2189.   if (may_be_alloca && nonlocal_goto_handler_slot != 0)
  2190.     emit_stack_save (SAVE_NONLOCAL, &nonlocal_goto_stack_level, NULL_RTX);
  2191.  
  2192.   pop_temp_slots ();
  2193.  
  2194.   return target;
  2195. }
  2196.  
  2197. /* Output a library call to function FUN (a SYMBOL_REF rtx)
  2198.    (emitting the queue unless NO_QUEUE is nonzero),
  2199.    for a value of mode OUTMODE,
  2200.    with NARGS different arguments, passed as alternating rtx values
  2201.    and machine_modes to convert them to.
  2202.    The rtx values should have been passed through protect_from_queue already.
  2203.  
  2204.    NO_QUEUE will be true if and only if the library call is a `const' call
  2205.    which will be enclosed in REG_LIBCALL/REG_RETVAL notes; it is equivalent
  2206.    to the variable is_const in expand_call.
  2207.  
  2208.    NO_QUEUE must be true for const calls, because if it isn't, then
  2209.    any pending increment will be emitted between REG_LIBCALL/REG_RETVAL notes,
  2210.    and will be lost if the libcall sequence is optimized away.
  2211.  
  2212.    NO_QUEUE must be false for non-const calls, because if it isn't, the
  2213.    call insn will have its CONST_CALL_P bit set, and it will be incorrectly
  2214.    optimized.  For instance, the instruction scheduler may incorrectly
  2215.    move memory references across the non-const call.  */
  2216.  
  2217. void
  2218. emit_library_call VPROTO((rtx orgfun, int no_queue, enum machine_mode outmode,
  2219.               int nargs, ...))
  2220. {
  2221. #ifndef __STDC__
  2222.   rtx orgfun;
  2223.   int no_queue;
  2224.   enum machine_mode outmode;
  2225.   int nargs;
  2226. #endif
  2227.   va_list p;
  2228.   /* Total size in bytes of all the stack-parms scanned so far.  */
  2229.   struct args_size args_size;
  2230.   /* Size of arguments before any adjustments (such as rounding).  */
  2231.   struct args_size original_args_size;
  2232.   register int argnum;
  2233.   rtx fun;
  2234.   int inc;
  2235.   int count;
  2236.   rtx argblock = 0;
  2237.   CUMULATIVE_ARGS args_so_far;
  2238.   struct arg { rtx value; enum machine_mode mode; rtx reg; int partial;
  2239.            struct args_size offset; struct args_size size; };
  2240.   struct arg *argvec;
  2241.   int old_inhibit_defer_pop = inhibit_defer_pop;
  2242.   rtx call_fusage = 0;
  2243.   /* library calls are never indirect calls.  */
  2244.   int current_call_is_indirect = 0;
  2245.  
  2246.   VA_START (p, nargs);
  2247.  
  2248. #ifndef __STDC__
  2249.   orgfun = va_arg (p, rtx);
  2250.   no_queue = va_arg (p, int);
  2251.   outmode = va_arg (p, enum machine_mode);
  2252.   nargs = va_arg (p, int);
  2253. #endif
  2254.  
  2255.   fun = orgfun;
  2256.  
  2257.   /* Copy all the libcall-arguments out of the varargs data
  2258.      and into a vector ARGVEC.
  2259.  
  2260.      Compute how to pass each argument.  We only support a very small subset
  2261.      of the full argument passing conventions to limit complexity here since
  2262.      library functions shouldn't have many args.  */
  2263.  
  2264.   argvec = (struct arg *) alloca (nargs * sizeof (struct arg));
  2265.  
  2266. #if defined (__amigados__)
  2267. /* how would you do this RIGHT ?? fake a DECL node? dunno... */
  2268. #ifdef ENCODE_SECTION_INFO
  2269.   /* mark it as a function (to be in the text section that is) */
  2270.   SYMBOL_REF_FLAG (fun) = 1;
  2271. #endif
  2272. #endif
  2273.  
  2274.   INIT_CUMULATIVE_ARGS (args_so_far, NULL_TREE, fun);
  2275.  
  2276.   args_size.constant = 0;
  2277.   args_size.var = 0;
  2278.  
  2279.   push_temp_slots ();
  2280.  
  2281.   for (count = 0; count < nargs; count++)
  2282.     {
  2283.       rtx val = va_arg (p, rtx);
  2284.       enum machine_mode mode = va_arg (p, enum machine_mode);
  2285.  
  2286.       /* We cannot convert the arg value to the mode the library wants here;
  2287.      must do it earlier where we know the signedness of the arg.  */
  2288.       if (mode == BLKmode
  2289.       || (GET_MODE (val) != mode && GET_MODE (val) != VOIDmode))
  2290.     abort ();
  2291.  
  2292.       /* On some machines, there's no way to pass a float to a library fcn.
  2293.      Pass it as a double instead.  */
  2294. #ifdef LIBGCC_NEEDS_DOUBLE
  2295.       if (LIBGCC_NEEDS_DOUBLE && mode == SFmode)
  2296.     val = convert_modes (DFmode, SFmode, val, 0), mode = DFmode;
  2297. #endif
  2298.  
  2299.       /* There's no need to call protect_from_queue, because
  2300.      either emit_move_insn or emit_push_insn will do that.  */
  2301.  
  2302.       /* Make sure it is a reasonable operand for a move or push insn.  */
  2303.       if (GET_CODE (val) != REG && GET_CODE (val) != MEM
  2304.       && ! (CONSTANT_P (val) && LEGITIMATE_CONSTANT_P (val)))
  2305.     val = force_operand (val, NULL_RTX);
  2306.  
  2307. #ifdef FUNCTION_ARG_PASS_BY_REFERENCE
  2308.       if (FUNCTION_ARG_PASS_BY_REFERENCE (args_so_far, mode, NULL_TREE, 1))
  2309.     {
  2310.       /* We do not support FUNCTION_ARG_CALLEE_COPIES here since it can
  2311.          be viewed as just an efficiency improvement.  */
  2312.       rtx slot = assign_stack_temp (mode, GET_MODE_SIZE (mode), 0);
  2313.       emit_move_insn (slot, val);
  2314.       val = force_operand (XEXP (slot, 0), NULL_RTX);
  2315.       mode = Pmode;
  2316.     }
  2317. #endif
  2318.  
  2319.       argvec[count].value = val;
  2320.       argvec[count].mode = mode;
  2321.  
  2322.       argvec[count].reg = FUNCTION_ARG (args_so_far, mode, NULL_TREE, 1);
  2323.       if (argvec[count].reg && GET_CODE (argvec[count].reg) == EXPR_LIST)
  2324.     abort ();
  2325. #ifdef FUNCTION_ARG_PARTIAL_NREGS
  2326.       argvec[count].partial
  2327.     = FUNCTION_ARG_PARTIAL_NREGS (args_so_far, mode, NULL_TREE, 1);
  2328. #else
  2329.       argvec[count].partial = 0;
  2330. #endif
  2331.  
  2332.       locate_and_pad_parm (mode, NULL_TREE,
  2333.                argvec[count].reg && argvec[count].partial == 0,
  2334.                NULL_TREE, &args_size, &argvec[count].offset,
  2335.                &argvec[count].size);
  2336.  
  2337.       if (argvec[count].size.var)
  2338.     abort ();
  2339.  
  2340. #ifndef REG_PARM_STACK_SPACE
  2341.       if (argvec[count].partial)
  2342.     argvec[count].size.constant -= argvec[count].partial * UNITS_PER_WORD;
  2343. #endif
  2344.  
  2345.       if (argvec[count].reg == 0 || argvec[count].partial != 0
  2346. #ifdef REG_PARM_STACK_SPACE
  2347.       || 1
  2348. #endif
  2349.       )
  2350.     args_size.constant += argvec[count].size.constant;
  2351.  
  2352. #ifdef ACCUMULATE_OUTGOING_ARGS
  2353.       /* If this arg is actually passed on the stack, it might be
  2354.      clobbering something we already put there (this library call might
  2355.      be inside the evaluation of an argument to a function whose call
  2356.      requires the stack).  This will only occur when the library call
  2357.      has sufficient args to run out of argument registers.  Abort in
  2358.      this case; if this ever occurs, code must be added to save and
  2359.      restore the arg slot.  */
  2360.  
  2361.       if (argvec[count].reg == 0 || argvec[count].partial != 0)
  2362.     abort ();
  2363. #endif
  2364.  
  2365.       FUNCTION_ARG_ADVANCE (args_so_far, mode, (tree)0, 1);
  2366.     }
  2367.   va_end (p);
  2368.  
  2369.   /* If this machine requires an external definition for library
  2370.      functions, write one out.  */
  2371.   assemble_external_libcall (fun);
  2372.  
  2373.   original_args_size = args_size;
  2374. #ifdef STACK_BOUNDARY
  2375.   args_size.constant = (((args_size.constant + (STACK_BYTES - 1))
  2376.              / STACK_BYTES) * STACK_BYTES);
  2377. #endif
  2378.  
  2379. #ifdef REG_PARM_STACK_SPACE
  2380.   args_size.constant = MAX (args_size.constant,
  2381.                 REG_PARM_STACK_SPACE (NULL_TREE));
  2382. #ifndef OUTGOING_REG_PARM_STACK_SPACE
  2383.   args_size.constant -= REG_PARM_STACK_SPACE (NULL_TREE);
  2384. #endif
  2385. #endif
  2386.  
  2387.   if (args_size.constant > current_function_outgoing_args_size)
  2388.     current_function_outgoing_args_size = args_size.constant;
  2389.  
  2390. #ifdef ACCUMULATE_OUTGOING_ARGS
  2391.   args_size.constant = 0;
  2392. #endif
  2393.  
  2394. #ifndef PUSH_ROUNDING
  2395.   argblock = push_block (GEN_INT (args_size.constant), 0, 0);
  2396. #endif
  2397.  
  2398. #ifdef PUSH_ARGS_REVERSED
  2399. #ifdef STACK_BOUNDARY
  2400.   /* If we push args individually in reverse order, perform stack alignment
  2401.      before the first push (the last arg).  */
  2402.   if (argblock == 0)
  2403.     anti_adjust_stack (GEN_INT (args_size.constant
  2404.                 - original_args_size.constant));
  2405. #endif
  2406. #endif
  2407.  
  2408. #ifdef PUSH_ARGS_REVERSED
  2409.   inc = -1;
  2410.   argnum = nargs - 1;
  2411. #else
  2412.   inc = 1;
  2413.   argnum = 0;
  2414. #endif
  2415.  
  2416.   /* Push the args that need to be pushed.  */
  2417.  
  2418.   for (count = 0; count < nargs; count++, argnum += inc)
  2419.     {
  2420.       register enum machine_mode mode = argvec[argnum].mode;
  2421.       register rtx val = argvec[argnum].value;
  2422.       rtx reg = argvec[argnum].reg;
  2423.       int partial = argvec[argnum].partial;
  2424.  
  2425.       if (! (reg != 0 && partial == 0))
  2426.     emit_push_insn (val, mode, NULL_TREE, NULL_RTX, 0, partial, reg, 0,
  2427.             argblock, GEN_INT (argvec[count].offset.constant));
  2428.       NO_DEFER_POP;
  2429.     }
  2430.  
  2431. #ifndef PUSH_ARGS_REVERSED
  2432. #ifdef STACK_BOUNDARY
  2433.   /* If we pushed args in forward order, perform stack alignment
  2434.      after pushing the last arg.  */
  2435.   if (argblock == 0)
  2436.     anti_adjust_stack (GEN_INT (args_size.constant
  2437.                 - original_args_size.constant));
  2438. #endif
  2439. #endif
  2440.  
  2441. #ifdef PUSH_ARGS_REVERSED
  2442.   argnum = nargs - 1;
  2443. #else
  2444.   argnum = 0;
  2445. #endif
  2446.  
  2447.   fun = prepare_call_address (fun, NULL_TREE, &call_fusage, 0);
  2448.  
  2449.   /* Now load any reg parms into their regs.  */
  2450.  
  2451.   for (count = 0; count < nargs; count++, argnum += inc)
  2452.     {
  2453.       register enum machine_mode mode = argvec[argnum].mode;
  2454.       register rtx val = argvec[argnum].value;
  2455.       rtx reg = argvec[argnum].reg;
  2456.       int partial = argvec[argnum].partial;
  2457.  
  2458.       if (reg != 0 && partial == 0)
  2459.     emit_move_insn (reg, val);
  2460.       NO_DEFER_POP;
  2461.     }
  2462.  
  2463.   /* For version 1.37, try deleting this entirely.  */
  2464.   if (! no_queue)
  2465.     emit_queue ();
  2466.  
  2467.   /* Any regs containing parms remain in use through the call.  */
  2468.   for (count = 0; count < nargs; count++)
  2469.     if (argvec[count].reg != 0)
  2470.        use_reg (&call_fusage, argvec[count].reg);
  2471.  
  2472.   /* Don't allow popping to be deferred, since then
  2473.      cse'ing of library calls could delete a call and leave the pop.  */
  2474.   NO_DEFER_POP;
  2475.  
  2476.   /* We pass the old value of inhibit_defer_pop + 1 to emit_call_1, which
  2477.      will set inhibit_defer_pop to that value.  */
  2478.  
  2479.   emit_call_1 (fun, 
  2480.                get_identifier (XSTR (orgfun, 0)), 
  2481.                get_identifier (XSTR (orgfun, 0)), args_size.constant, 0,
  2482.            FUNCTION_ARG (args_so_far, VOIDmode, void_type_node, 1),
  2483.            outmode != VOIDmode ? hard_libcall_value (outmode) : NULL_RTX,
  2484.            old_inhibit_defer_pop + 1, call_fusage, no_queue);
  2485.  
  2486.   pop_temp_slots ();
  2487.  
  2488.   /* Now restore inhibit_defer_pop to its actual original value.  */
  2489.   OK_DEFER_POP;
  2490. }
  2491.  
  2492. /* Like emit_library_call except that an extra argument, VALUE,
  2493.    comes second and says where to store the result.
  2494.    (If VALUE is zero, this function chooses a convenient way
  2495.    to return the value.
  2496.  
  2497.    This function returns an rtx for where the value is to be found.
  2498.    If VALUE is nonzero, VALUE is returned.  */
  2499.  
  2500. rtx
  2501. emit_library_call_value VPROTO((rtx orgfun, rtx value, int no_queue,
  2502.                 enum machine_mode outmode, int nargs, ...))
  2503. {
  2504. #ifndef __STDC__
  2505.   rtx orgfun;
  2506.   rtx value;
  2507.   int no_queue;
  2508.   enum machine_mode outmode;
  2509.   int nargs;
  2510. #endif
  2511.   va_list p;
  2512.   /* Total size in bytes of all the stack-parms scanned so far.  */
  2513.   struct args_size args_size;
  2514.   /* Size of arguments before any adjustments (such as rounding).  */
  2515.   struct args_size original_args_size;
  2516.   register int argnum;
  2517.   rtx fun;
  2518.   int inc;
  2519.   int count;
  2520.   rtx argblock = 0;
  2521.   CUMULATIVE_ARGS args_so_far;
  2522.   struct arg { rtx value; enum machine_mode mode; rtx reg; int partial;
  2523.            struct args_size offset; struct args_size size; };
  2524.   struct arg *argvec;
  2525.   int old_inhibit_defer_pop = inhibit_defer_pop;
  2526.   rtx call_fusage = 0;
  2527.   rtx mem_value = 0;
  2528.   int pcc_struct_value = 0;
  2529.   int struct_value_size = 0;
  2530.   /* library calls are never indirect calls.  */
  2531.   int current_call_is_indirect = 0;
  2532.   int is_const;
  2533.  
  2534.   VA_START (p, nargs);
  2535.  
  2536. #ifndef __STDC__
  2537.   orgfun = va_arg (p, rtx);
  2538.   value = va_arg (p, rtx);
  2539.   no_queue = va_arg (p, int);
  2540.   outmode = va_arg (p, enum machine_mode);
  2541.   nargs = va_arg (p, int);
  2542. #endif
  2543.  
  2544.   is_const = no_queue;
  2545.   fun = orgfun;
  2546.  
  2547.   /* If this kind of value comes back in memory,
  2548.      decide where in memory it should come back.  */
  2549.   if (aggregate_value_p (type_for_mode (outmode, 0)))
  2550.     {
  2551. #ifdef PCC_STATIC_STRUCT_RETURN
  2552.       rtx pointer_reg
  2553.     = hard_function_value (build_pointer_type (type_for_mode (outmode, 0)),
  2554.                    0);
  2555.       mem_value = gen_rtx (MEM, outmode, pointer_reg);
  2556.       pcc_struct_value = 1;
  2557.       if (value == 0)
  2558.     value = gen_reg_rtx (outmode);
  2559. #else /* not PCC_STATIC_STRUCT_RETURN */
  2560.       struct_value_size = GET_MODE_SIZE (outmode);
  2561.       if (value != 0 && GET_CODE (value) == MEM)
  2562.     mem_value = value;
  2563.       else
  2564.     mem_value = assign_stack_temp (outmode, GET_MODE_SIZE (outmode), 0);
  2565. #endif
  2566.  
  2567.       /* This call returns a big structure.  */
  2568.       is_const = 0;
  2569.     }
  2570.  
  2571.   /* ??? Unfinished: must pass the memory address as an argument.  */
  2572.  
  2573.   /* Copy all the libcall-arguments out of the varargs data
  2574.      and into a vector ARGVEC.
  2575.  
  2576.      Compute how to pass each argument.  We only support a very small subset
  2577.      of the full argument passing conventions to limit complexity here since
  2578.      library functions shouldn't have many args.  */
  2579.  
  2580.   argvec = (struct arg *) alloca ((nargs + 1) * sizeof (struct arg));
  2581.  
  2582. #if defined (__amigados__)
  2583. /* how would you do this RIGHT ?? fake a DECL node? dunno... */
  2584. #ifdef ENCODE_SECTION_INFO
  2585.   /* mark it as a function (to be in the text section that is) */
  2586.   SYMBOL_REF_FLAG (fun) = 1;
  2587. #endif
  2588. #endif
  2589.  
  2590.   INIT_CUMULATIVE_ARGS (args_so_far, NULL_TREE, fun);
  2591.  
  2592.   args_size.constant = 0;
  2593.   args_size.var = 0;
  2594.  
  2595.   count = 0;
  2596.  
  2597.   push_temp_slots ();
  2598.  
  2599.   /* If there's a structure value address to be passed,
  2600.      either pass it in the special place, or pass it as an extra argument.  */
  2601.   if (mem_value && struct_value_rtx == 0 && ! pcc_struct_value)
  2602.     {
  2603.       rtx addr = XEXP (mem_value, 0);
  2604.       nargs++;
  2605.  
  2606.       /* Make sure it is a reasonable operand for a move or push insn.  */
  2607.       if (GET_CODE (addr) != REG && GET_CODE (addr) != MEM
  2608.       && ! (CONSTANT_P (addr) && LEGITIMATE_CONSTANT_P (addr)))
  2609.     addr = force_operand (addr, NULL_RTX);
  2610.  
  2611.       argvec[count].value = addr;
  2612.       argvec[count].mode = Pmode;
  2613.       argvec[count].partial = 0;
  2614.  
  2615.       argvec[count].reg = FUNCTION_ARG (args_so_far, Pmode, NULL_TREE, 1);
  2616. #ifdef FUNCTION_ARG_PARTIAL_NREGS
  2617.       if (FUNCTION_ARG_PARTIAL_NREGS (args_so_far, Pmode, NULL_TREE, 1))
  2618.     abort ();
  2619. #endif
  2620.  
  2621.       locate_and_pad_parm (Pmode, NULL_TREE,
  2622.                argvec[count].reg && argvec[count].partial == 0,
  2623.                NULL_TREE, &args_size, &argvec[count].offset,
  2624.                &argvec[count].size);
  2625.  
  2626.  
  2627.       if (argvec[count].reg == 0 || argvec[count].partial != 0
  2628. #ifdef REG_PARM_STACK_SPACE
  2629.       || 1
  2630. #endif
  2631.       )
  2632.     args_size.constant += argvec[count].size.constant;
  2633.  
  2634.       FUNCTION_ARG_ADVANCE (args_so_far, Pmode, (tree)0, 1);
  2635.  
  2636.       count++;
  2637.     }
  2638.  
  2639.   for (; count < nargs; count++)
  2640.     {
  2641.       rtx val = va_arg (p, rtx);
  2642.       enum machine_mode mode = va_arg (p, enum machine_mode);
  2643.  
  2644.       /* We cannot convert the arg value to the mode the library wants here;
  2645.      must do it earlier where we know the signedness of the arg.  */
  2646.       if (mode == BLKmode
  2647.       || (GET_MODE (val) != mode && GET_MODE (val) != VOIDmode))
  2648.     abort ();
  2649.  
  2650.       /* On some machines, there's no way to pass a float to a library fcn.
  2651.      Pass it as a double instead.  */
  2652. #ifdef LIBGCC_NEEDS_DOUBLE
  2653.       if (LIBGCC_NEEDS_DOUBLE && mode == SFmode)
  2654.     val = convert_modes (DFmode, SFmode, val, 0), mode = DFmode;
  2655. #endif
  2656.  
  2657.       /* There's no need to call protect_from_queue, because
  2658.      either emit_move_insn or emit_push_insn will do that.  */
  2659.  
  2660.       /* Make sure it is a reasonable operand for a move or push insn.  */
  2661.       if (GET_CODE (val) != REG && GET_CODE (val) != MEM
  2662.       && ! (CONSTANT_P (val) && LEGITIMATE_CONSTANT_P (val)))
  2663.     val = force_operand (val, NULL_RTX);
  2664.  
  2665. #ifdef FUNCTION_ARG_PASS_BY_REFERENCE
  2666.       if (FUNCTION_ARG_PASS_BY_REFERENCE (args_so_far, mode, NULL_TREE, 1))
  2667.     {
  2668.       /* We do not support FUNCTION_ARG_CALLEE_COPIES here since it can
  2669.          be viewed as just an efficiency improvement.  */
  2670.       rtx slot = assign_stack_temp (mode, GET_MODE_SIZE (mode), 0);
  2671.       emit_move_insn (slot, val);
  2672.       val = XEXP (slot, 0);
  2673.       mode = Pmode;
  2674.     }
  2675. #endif
  2676.  
  2677.       argvec[count].value = val;
  2678.       argvec[count].mode = mode;
  2679.  
  2680.       argvec[count].reg = FUNCTION_ARG (args_so_far, mode, NULL_TREE, 1);
  2681.       if (argvec[count].reg && GET_CODE (argvec[count].reg) == EXPR_LIST)
  2682.     abort ();
  2683. #ifdef FUNCTION_ARG_PARTIAL_NREGS
  2684.       argvec[count].partial
  2685.     = FUNCTION_ARG_PARTIAL_NREGS (args_so_far, mode, NULL_TREE, 1);
  2686. #else
  2687.       argvec[count].partial = 0;
  2688. #endif
  2689.  
  2690.       locate_and_pad_parm (mode, NULL_TREE,
  2691.                argvec[count].reg && argvec[count].partial == 0,
  2692.                NULL_TREE, &args_size, &argvec[count].offset,
  2693.                &argvec[count].size);
  2694.  
  2695.       if (argvec[count].size.var)
  2696.     abort ();
  2697.  
  2698. #ifndef REG_PARM_STACK_SPACE
  2699.       if (argvec[count].partial)
  2700.     argvec[count].size.constant -= argvec[count].partial * UNITS_PER_WORD;
  2701. #endif
  2702.  
  2703.       if (argvec[count].reg == 0 || argvec[count].partial != 0
  2704. #ifdef REG_PARM_STACK_SPACE
  2705.       || 1
  2706. #endif
  2707.       )
  2708.     args_size.constant += argvec[count].size.constant;
  2709.  
  2710. #ifdef ACCUMULATE_OUTGOING_ARGS
  2711.       /* If this arg is actually passed on the stack, it might be
  2712.      clobbering something we already put there (this library call might
  2713.      be inside the evaluation of an argument to a function whose call
  2714.      requires the stack).  This will only occur when the library call
  2715.      has sufficient args to run out of argument registers.  Abort in
  2716.      this case; if this ever occurs, code must be added to save and
  2717.      restore the arg slot.  */
  2718.  
  2719.       if (argvec[count].reg == 0 || argvec[count].partial != 0)
  2720.     abort ();
  2721. #endif
  2722.  
  2723.       FUNCTION_ARG_ADVANCE (args_so_far, mode, (tree)0, 1);
  2724.     }
  2725.   va_end (p);
  2726.  
  2727.   /* If this machine requires an external definition for library
  2728.      functions, write one out.  */
  2729.   assemble_external_libcall (fun);
  2730.  
  2731.   original_args_size = args_size;
  2732. #ifdef STACK_BOUNDARY
  2733.   args_size.constant = (((args_size.constant + (STACK_BYTES - 1))
  2734.              / STACK_BYTES) * STACK_BYTES);
  2735. #endif
  2736.  
  2737. #ifdef REG_PARM_STACK_SPACE
  2738.   args_size.constant = MAX (args_size.constant,
  2739.                 REG_PARM_STACK_SPACE (NULL_TREE));
  2740. #ifndef OUTGOING_REG_PARM_STACK_SPACE
  2741.   args_size.constant -= REG_PARM_STACK_SPACE (NULL_TREE);
  2742. #endif
  2743. #endif
  2744.  
  2745.   if (args_size.constant > current_function_outgoing_args_size)
  2746.     current_function_outgoing_args_size = args_size.constant;
  2747.  
  2748. #ifdef ACCUMULATE_OUTGOING_ARGS
  2749.   args_size.constant = 0;
  2750. #endif
  2751.  
  2752. #ifndef PUSH_ROUNDING
  2753.   argblock = push_block (GEN_INT (args_size.constant), 0, 0);
  2754. #endif
  2755.  
  2756. #ifdef PUSH_ARGS_REVERSED
  2757. #ifdef STACK_BOUNDARY
  2758.   /* If we push args individually in reverse order, perform stack alignment
  2759.      before the first push (the last arg).  */
  2760.   if (argblock == 0)
  2761.     anti_adjust_stack (GEN_INT (args_size.constant
  2762.                 - original_args_size.constant));
  2763. #endif
  2764. #endif
  2765.  
  2766. #ifdef PUSH_ARGS_REVERSED
  2767.   inc = -1;
  2768.   argnum = nargs - 1;
  2769. #else
  2770.   inc = 1;
  2771.   argnum = 0;
  2772. #endif
  2773.  
  2774.   /* Push the args that need to be pushed.  */
  2775.  
  2776.   for (count = 0; count < nargs; count++, argnum += inc)
  2777.     {
  2778.       register enum machine_mode mode = argvec[argnum].mode;
  2779.       register rtx val = argvec[argnum].value;
  2780.       rtx reg = argvec[argnum].reg;
  2781.       int partial = argvec[argnum].partial;
  2782.  
  2783.       if (! (reg != 0 && partial == 0))
  2784.     emit_push_insn (val, mode, NULL_TREE, NULL_RTX, 0, partial, reg, 0,
  2785.             argblock, GEN_INT (argvec[count].offset.constant));
  2786.       NO_DEFER_POP;
  2787.     }
  2788.  
  2789. #ifndef PUSH_ARGS_REVERSED
  2790. #ifdef STACK_BOUNDARY
  2791.   /* If we pushed args in forward order, perform stack alignment
  2792.      after pushing the last arg.  */
  2793.   if (argblock == 0)
  2794.     anti_adjust_stack (GEN_INT (args_size.constant
  2795.                 - original_args_size.constant));
  2796. #endif
  2797. #endif
  2798.  
  2799. #ifdef PUSH_ARGS_REVERSED
  2800.   argnum = nargs - 1;
  2801. #else
  2802.   argnum = 0;
  2803. #endif
  2804.  
  2805.   fun = prepare_call_address (fun, NULL_TREE, &call_fusage, 0);
  2806.  
  2807.   /* Now load any reg parms into their regs.  */
  2808.  
  2809.   for (count = 0; count < nargs; count++, argnum += inc)
  2810.     {
  2811.       register enum machine_mode mode = argvec[argnum].mode;
  2812.       register rtx val = argvec[argnum].value;
  2813.       rtx reg = argvec[argnum].reg;
  2814.       int partial = argvec[argnum].partial;
  2815.  
  2816.       if (reg != 0 && partial == 0)
  2817.     emit_move_insn (reg, val);
  2818.       NO_DEFER_POP;
  2819.     }
  2820.  
  2821. #if 0
  2822.   /* For version 1.37, try deleting this entirely.  */
  2823.   if (! no_queue)
  2824.     emit_queue ();
  2825. #endif
  2826.  
  2827.   /* Any regs containing parms remain in use through the call.  */
  2828.   for (count = 0; count < nargs; count++)
  2829.     if (argvec[count].reg != 0)
  2830.        use_reg (&call_fusage, argvec[count].reg);
  2831.  
  2832.   /* Pass the function the address in which to return a structure value.  */
  2833.   if (mem_value != 0 && struct_value_rtx != 0 && ! pcc_struct_value)
  2834.     {
  2835.       emit_move_insn (struct_value_rtx,
  2836.               force_reg (Pmode,
  2837.                  force_operand (XEXP (mem_value, 0),
  2838.                         NULL_RTX)));
  2839.       if (GET_CODE (struct_value_rtx) == REG)
  2840.       use_reg (&call_fusage, struct_value_rtx);
  2841.     }
  2842.  
  2843.   /* Don't allow popping to be deferred, since then
  2844.      cse'ing of library calls could delete a call and leave the pop.  */
  2845.   NO_DEFER_POP;
  2846.  
  2847.   /* We pass the old value of inhibit_defer_pop + 1 to emit_call_1, which
  2848.      will set inhibit_defer_pop to that value.  */
  2849.  
  2850.   emit_call_1 (fun, 
  2851.                get_identifier (XSTR (orgfun, 0)),
  2852.                get_identifier (XSTR (orgfun, 0)), args_size.constant,
  2853.            struct_value_size,
  2854.            FUNCTION_ARG (args_so_far, VOIDmode, void_type_node, 1),
  2855.            (outmode != VOIDmode && mem_value == 0
  2856.         ? hard_libcall_value (outmode) : NULL_RTX),
  2857.            old_inhibit_defer_pop + 1, call_fusage, is_const);
  2858.  
  2859.   /* Now restore inhibit_defer_pop to its actual original value.  */
  2860.   OK_DEFER_POP;
  2861.  
  2862.   pop_temp_slots ();
  2863.  
  2864.   /* Copy the value to the right place.  */
  2865.   if (outmode != VOIDmode)
  2866.     {
  2867.       if (mem_value)
  2868.     {
  2869.       if (value == 0)
  2870.         value = mem_value;
  2871.       if (value != mem_value)
  2872.         emit_move_insn (value, mem_value);
  2873.     }
  2874.       else if (value != 0)
  2875.     emit_move_insn (value, hard_libcall_value (outmode));
  2876.       else
  2877.     value = hard_libcall_value (outmode);
  2878.     }
  2879.  
  2880.   return value;
  2881. }
  2882.  
  2883. #if 0
  2884. /* Return an rtx which represents a suitable home on the stack
  2885.    given TYPE, the type of the argument looking for a home.
  2886.    This is called only for BLKmode arguments.
  2887.  
  2888.    SIZE is the size needed for this target.
  2889.    ARGS_ADDR is the address of the bottom of the argument block for this call.
  2890.    OFFSET describes this parameter's offset into ARGS_ADDR.  It is meaningless
  2891.    if this machine uses push insns.  */
  2892.  
  2893. static rtx
  2894. target_for_arg (type, size, args_addr, offset)
  2895.      tree type;
  2896.      rtx size;
  2897.      rtx args_addr;
  2898.      struct args_size offset;
  2899. {
  2900.   rtx target;
  2901.   rtx offset_rtx = ARGS_SIZE_RTX (offset);
  2902.  
  2903.   /* We do not call memory_address if possible,
  2904.      because we want to address as close to the stack
  2905.      as possible.  For non-variable sized arguments,
  2906.      this will be stack-pointer relative addressing.  */
  2907.   if (GET_CODE (offset_rtx) == CONST_INT)
  2908.     target = plus_constant (args_addr, INTVAL (offset_rtx));
  2909.   else
  2910.     {
  2911.       /* I have no idea how to guarantee that this
  2912.      will work in the presence of register parameters.  */
  2913.       target = gen_rtx (PLUS, Pmode, args_addr, offset_rtx);
  2914.       target = memory_address (QImode, target);
  2915.     }
  2916.  
  2917.   return gen_rtx (MEM, BLKmode, target);
  2918. }
  2919. #endif
  2920.  
  2921. /* Store a single argument for a function call
  2922.    into the register or memory area where it must be passed.
  2923.    *ARG describes the argument value and where to pass it.
  2924.  
  2925.    ARGBLOCK is the address of the stack-block for all the arguments,
  2926.    or 0 on a machine where arguments are pushed individually.
  2927.  
  2928.    MAY_BE_ALLOCA nonzero says this could be a call to `alloca'
  2929.    so must be careful about how the stack is used. 
  2930.  
  2931.    VARIABLE_SIZE nonzero says that this was a variable-sized outgoing
  2932.    argument stack.  This is used if ACCUMULATE_OUTGOING_ARGS to indicate
  2933.    that we need not worry about saving and restoring the stack.
  2934.  
  2935.    FNDECL is the declaration of the function we are calling.  */
  2936.  
  2937. static void
  2938. store_one_arg (arg, argblock, may_be_alloca, variable_size, fndecl,
  2939.            reg_parm_stack_space)
  2940.      struct arg_data *arg;
  2941.      rtx argblock;
  2942.      int may_be_alloca;
  2943.      int variable_size;
  2944.      tree fndecl;
  2945.      int reg_parm_stack_space;
  2946. {
  2947.   register tree pval = arg->tree_value;
  2948.   rtx reg = 0;
  2949.   int partial = 0;
  2950.   int used = 0;
  2951.   int i, lower_bound, upper_bound;
  2952.  
  2953.   if (TREE_CODE (pval) == ERROR_MARK)
  2954.     return;
  2955.  
  2956.   /* Push a new temporary level for any temporaries we make for
  2957.      this argument.  */
  2958.   push_temp_slots ();
  2959.  
  2960. #ifdef ACCUMULATE_OUTGOING_ARGS
  2961.   /* If this is being stored into a pre-allocated, fixed-size, stack area,
  2962.      save any previous data at that location.  */
  2963.   if (argblock && ! variable_size && arg->stack)
  2964.     {
  2965. #ifdef ARGS_GROW_DOWNWARD
  2966.       /* stack_slot is negative, but we want to index stack_usage_map */
  2967.       /* with positive values. */
  2968.       if (GET_CODE (XEXP (arg->stack_slot, 0)) == PLUS)
  2969.     upper_bound = -INTVAL (XEXP (XEXP (arg->stack_slot, 0), 1)) + 1;
  2970.       else
  2971.     abort ();
  2972.  
  2973.       lower_bound = upper_bound - arg->size.constant;
  2974. #else
  2975.       if (GET_CODE (XEXP (arg->stack_slot, 0)) == PLUS)
  2976.     lower_bound = INTVAL (XEXP (XEXP (arg->stack_slot, 0), 1));
  2977.       else
  2978.     lower_bound = 0;
  2979.  
  2980.       upper_bound = lower_bound + arg->size.constant;
  2981. #endif
  2982.  
  2983.       for (i = lower_bound; i < upper_bound; i++)
  2984.     if (stack_usage_map[i]
  2985. #ifdef REG_PARM_STACK_SPACE
  2986.         /* Don't store things in the fixed argument area at this point;
  2987.            it has already been saved.  */
  2988.         && i > reg_parm_stack_space
  2989. #endif
  2990.         )
  2991.       break;
  2992.  
  2993.       if (i != upper_bound)
  2994.     {
  2995.       /* We need to make a save area.  See what mode we can make it.  */
  2996.       enum machine_mode save_mode
  2997.         = mode_for_size (arg->size.constant * BITS_PER_UNIT, MODE_INT, 1);
  2998.       rtx stack_area
  2999.         = gen_rtx (MEM, save_mode,
  3000.                memory_address (save_mode, XEXP (arg->stack_slot, 0)));
  3001.  
  3002.       if (save_mode == BLKmode)
  3003.         {
  3004.           arg->save_area = assign_stack_temp (BLKmode,
  3005.                           arg->size.constant, 0);
  3006.           MEM_IN_STRUCT_P (arg->save_area)
  3007.         = AGGREGATE_TYPE_P (TREE_TYPE (arg->tree_value));
  3008.           preserve_temp_slots (arg->save_area);
  3009.           emit_block_move (validize_mem (arg->save_area), stack_area,
  3010.                    GEN_INT (arg->size.constant),
  3011.                    PARM_BOUNDARY / BITS_PER_UNIT);
  3012.         }
  3013.       else
  3014.         {
  3015.           arg->save_area = gen_reg_rtx (save_mode);
  3016.           emit_move_insn (arg->save_area, stack_area);
  3017.         }
  3018.     }
  3019.     }
  3020. #endif
  3021.  
  3022.   /* If this isn't going to be placed on both the stack and in registers,
  3023.      set up the register and number of words.  */
  3024.   if (! arg->pass_on_stack)
  3025.     reg = arg->reg, partial = arg->partial;
  3026.  
  3027.   if (reg != 0 && partial == 0)
  3028.     /* Being passed entirely in a register.  We shouldn't be called in
  3029.        this case.   */
  3030.     abort ();
  3031.  
  3032. #ifdef STRICT_ALIGNMENT
  3033.   /* If this arg needs special alignment, don't load the registers
  3034.      here.  */
  3035.   if (arg->n_aligned_regs != 0)
  3036.     reg = 0;
  3037. #endif
  3038.   
  3039.   /* If this is being partially passed in a register, but multiple locations
  3040.      are specified, we assume that the one partially used is the one that is
  3041.      listed first.  */
  3042.   if (reg && GET_CODE (reg) == EXPR_LIST)
  3043.     reg = XEXP (reg, 0);
  3044.  
  3045.   /* If this is being passed partially in a register, we can't evaluate
  3046.      it directly into its stack slot.  Otherwise, we can.  */
  3047.   if (arg->value == 0)
  3048.     {
  3049. #ifdef ACCUMULATE_OUTGOING_ARGS
  3050.       /* stack_arg_under_construction is nonzero if a function argument is
  3051.      being evaluated directly into the outgoing argument list and
  3052.      expand_call must take special action to preserve the argument list
  3053.      if it is called recursively.
  3054.  
  3055.      For scalar function arguments stack_usage_map is sufficient to
  3056.      determine which stack slots must be saved and restored.  Scalar
  3057.      arguments in general have pass_on_stack == 0.
  3058.  
  3059.      If this argument is initialized by a function which takes the
  3060.      address of the argument (a C++ constructor or a C function
  3061.      returning a BLKmode structure), then stack_usage_map is
  3062.      insufficient and expand_call must push the stack around the
  3063.      function call.  Such arguments have pass_on_stack == 1.
  3064.  
  3065.      Note that it is always safe to set stack_arg_under_construction,
  3066.      but this generates suboptimal code if set when not needed.  */
  3067.  
  3068.       if (arg->pass_on_stack)
  3069.     stack_arg_under_construction++;
  3070. #endif
  3071.       arg->value = expand_expr (pval,
  3072.                 (partial
  3073.                  || TYPE_MODE (TREE_TYPE (pval)) != arg->mode)
  3074.                 ? NULL_RTX : arg->stack,
  3075.                 VOIDmode, 0);
  3076.  
  3077.       /* If we are promoting object (or for any other reason) the mode
  3078.      doesn't agree, convert the mode.  */
  3079.  
  3080.       if (arg->mode != TYPE_MODE (TREE_TYPE (pval)))
  3081.     arg->value = convert_modes (arg->mode, TYPE_MODE (TREE_TYPE (pval)),
  3082.                     arg->value, arg->unsignedp);
  3083.  
  3084. #ifdef ACCUMULATE_OUTGOING_ARGS
  3085.       if (arg->pass_on_stack)
  3086.     stack_arg_under_construction--;
  3087. #endif
  3088.     }
  3089.  
  3090.   /* Don't allow anything left on stack from computation
  3091.      of argument to alloca.  */
  3092.   if (may_be_alloca)
  3093.     do_pending_stack_adjust ();
  3094.  
  3095.   if (arg->value == arg->stack)
  3096.     /* If the value is already in the stack slot, we are done.  */
  3097.     ;
  3098.   else if (arg->mode != BLKmode)
  3099.     {
  3100.       register int size;
  3101.  
  3102.       /* Argument is a scalar, not entirely passed in registers.
  3103.      (If part is passed in registers, arg->partial says how much
  3104.      and emit_push_insn will take care of putting it there.)
  3105.      
  3106.      Push it, and if its size is less than the
  3107.      amount of space allocated to it,
  3108.      also bump stack pointer by the additional space.
  3109.      Note that in C the default argument promotions
  3110.      will prevent such mismatches.  */
  3111.  
  3112.       size = GET_MODE_SIZE (arg->mode);
  3113.       /* Compute how much space the push instruction will push.
  3114.      On many machines, pushing a byte will advance the stack
  3115.      pointer by a halfword.  */
  3116. #ifdef PUSH_ROUNDING
  3117.       size = PUSH_ROUNDING (size);
  3118. #endif
  3119.       used = size;
  3120.  
  3121.       /* Compute how much space the argument should get:
  3122.      round up to a multiple of the alignment for arguments.  */
  3123.       if (none != FUNCTION_ARG_PADDING (arg->mode, TREE_TYPE (pval)))
  3124.     used = (((size + PARM_BOUNDARY / BITS_PER_UNIT - 1)
  3125.          / (PARM_BOUNDARY / BITS_PER_UNIT))
  3126.         * (PARM_BOUNDARY / BITS_PER_UNIT));
  3127.  
  3128.       /* This isn't already where we want it on the stack, so put it there.
  3129.      This can either be done with push or copy insns.  */
  3130.       emit_push_insn (arg->value, arg->mode, TREE_TYPE (pval), NULL_RTX,
  3131.               0, partial, reg, used - size,
  3132.               argblock, ARGS_SIZE_RTX (arg->offset));
  3133.     }
  3134.   else
  3135.     {
  3136.       /* BLKmode, at least partly to be pushed.  */
  3137.  
  3138.       register int excess;
  3139.       rtx size_rtx;
  3140.  
  3141.       /* Pushing a nonscalar.
  3142.      If part is passed in registers, PARTIAL says how much
  3143.      and emit_push_insn will take care of putting it there.  */
  3144.  
  3145.       /* Round its size up to a multiple
  3146.      of the allocation unit for arguments.  */
  3147.  
  3148.       if (arg->size.var != 0)
  3149.     {
  3150.       excess = 0;
  3151.       size_rtx = ARGS_SIZE_RTX (arg->size);
  3152.     }
  3153.       else
  3154.     {
  3155.       /* PUSH_ROUNDING has no effect on us, because
  3156.          emit_push_insn for BLKmode is careful to avoid it.  */
  3157.       excess = (arg->size.constant - int_size_in_bytes (TREE_TYPE (pval))
  3158.             + partial * UNITS_PER_WORD);
  3159.       size_rtx = expr_size (pval);
  3160.     }
  3161.  
  3162.       emit_push_insn (arg->value, arg->mode, TREE_TYPE (pval), size_rtx,
  3163.               TYPE_ALIGN (TREE_TYPE (pval)) / BITS_PER_UNIT, partial,
  3164.               reg, excess, argblock, ARGS_SIZE_RTX (arg->offset));
  3165.     }
  3166.  
  3167.  
  3168.   /* Unless this is a partially-in-register argument, the argument is now
  3169.      in the stack. 
  3170.  
  3171.      ??? Note that this can change arg->value from arg->stack to
  3172.      arg->stack_slot and it matters when they are not the same.
  3173.      It isn't totally clear that this is correct in all cases.  */
  3174.   if (partial == 0)
  3175.     arg->value = arg->stack_slot;
  3176.  
  3177.   /* Once we have pushed something, pops can't safely
  3178.      be deferred during the rest of the arguments.  */
  3179.   NO_DEFER_POP;
  3180.  
  3181.   /* ANSI doesn't require a sequence point here,
  3182.      but PCC has one, so this will avoid some problems.  */
  3183.   emit_queue ();
  3184.  
  3185.   /* Free any temporary slots made in processing this argument.  Show
  3186.      that we might have taken the address of something and pushed that
  3187.      as an operand.  */
  3188.   preserve_temp_slots (NULL_RTX);
  3189.   free_temp_slots ();
  3190.   pop_temp_slots ();
  3191.  
  3192. #ifdef ACCUMULATE_OUTGOING_ARGS
  3193.   /* Now mark the segment we just used.  */
  3194.   if (argblock && ! variable_size && arg->stack)
  3195.     for (i = lower_bound; i < upper_bound; i++)
  3196.       stack_usage_map[i] = 1;
  3197. #endif
  3198. }
  3199.